I have a problem where I read in a 2D matrix and divide the matrix into 2 parts, where the sums of each part are equal. Each part must contain contiguous integers that can be networked together by following paths from one intger containing cell to another via shared sides. The first matrix is:
4 4
50 85 9 33
301 46 40 19
105 29 11 12
20 13 23 16
The solution is:
301 + 105 = 406
50 + 85 + 9 + 33 + 46 + 40 + 19 + 20 + 29 + 11 + 12 + 13 + 23 + 16 = 406
I get the matrix read in and I added up all of the numbers and divided by 2. This gives me the total that each part should be equal to. Does anyone know how I should attempt to figure out which numbers I should try to add up in the array to get the correct total? I am at a loss there. Thanks for any input.