The goal is to end up with an array in which all entries are equal.
Four kinds of moves are allowed:
(1) rotate a row
(2) rotate a column
(3) add 1 to all entries in a row
(4) add 1 to all entries in a column
Show the goal is achievable if and only if the sum of the numbers in the initial configuration is congruent to 0 mod n.
Also write a python program to solve the puzzle whenever it is possible to do so.
It’s an interesting question for HN, so you should try resubmitting it
Perhaps there are some useful ideas in this code: https://www.chiark.greenend.org.uk/~sgtatham/puzzles