human
Minimum Cost to cut a board into squares | Method returns minimum cost to break board into m * n squares.
sort the horizontal cost in reverse order.
sort the vertical cost in reverse order.
initialize current width as 1.
loop until one or both cost array are processed.
increase current horizontal part count by 1.
increase current vertical part count by 1.
loop for horizontal array , if remains.
loop for vertical array , if remains.
Driver program"
Solution in Python:
assistant
#Here is code to minimum Cost to cut a board into squares and the other steps required.
 def minimumCostOfBreaking ( X , Y , m , n ) :
	res = 0
	X . sort ( reverse = True )
	Y . sort ( reverse = True )
	hzntl = 1 ; vert = 1
	i = 0 ; j = 0
	while ( i < m and j < n ) :
		if ( X [ i ] > Y [ j ] ) :
			res += X [ i ] * vert
			hzntl += 1
			i += 1
		else :
			res += Y [ j ] * hzntl
			vert += 1
			j += 1
	total = 0
	while ( i < m ) :
		total += X [ i ]
		i += 1
	res += total * vert
	total = 0
	while ( j < n ) :
		total += Y [ j ]
		j += 1
	res += total * hzntl
	return res
m = 6 ; n = 4
X = [ 2 , 1 , 3 , 1 , 4 ]
Y = [ 4 , 1 , 2 ]
print ( minimumCostOfBreaking ( X , Y , m - 1 , n - 1 ) )