3 ms·
It's actually pretty easy -- you can only change the total value of the board by n at a time (takes care of the "only if" part, because the "all equal" state al
by amalcon 19y ago
It's actually pretty easy -- you can only change the total value of the board by n at a time (takes care of the "only if" part, because the "all equal" state also requires the sum mod n to = 0). You can increase a single cell by n in exchange for increasing all cells (including that one) by 1 (by hitting the column it's in, then the row it's in, then rotating the column, repeat). You can spread the n part of that "increase" out over any number of cells you like, in any (whole) allocation you like, because it's clearly easy to put whatever cells you like in one column. So that lets you equalize everything as long as you move the deltas in clumps of n, which satisfies the "if" part.
- amichail 19y agoCould you give an example to illustrate your method?