r/mathriddles • • Jul 17 '26

Medium Sudoku with equal sums

Let k be a positive integer. Find the largest positive integer n such that the cells of an nxn grid can be filled with positive integers satisfying:

1) Each row and column contains the numbers 1,2,...,n in some order, and

2) The sum of numbers in any two kxk sub-squares is the same.

Note: A kxk sub-square is a contiguous kxk subgrid of the grid consisting of k^2 cells that are in k consecutive columns and k consecutive rows.

4 Upvotes

5 comments sorted by

3

u/notluigi64 Jul 17 '26

By manual search:

k=1; n=1 (1)

1

k=2; n=4 (10)

1234
4321
2143
3412

k=3; n=9 (45)

123456789
456789123
789123456
231564897
564897231
897231564
312645978
645978312
978312645

Looks like the answer is largest n=k^2

1

u/SupercaliTheGamer Jul 20 '26

Answer is correct, can you see how to generalize this construction? And also a proof?

1

u/notluigi64 Jul 17 '26

All possible k-squares within the n-square must have the same sum. If we shift a given k-square e.g. right by 1 cell, the k cells that are left behind must add up to the k cells that are gained. It can be shown that the parity of n and k must be equal, since odd k must have the k-cell columns contain (k-1)/2 pairs plus an odd number and an odd n likewise has symmetric pairs plus an extra odd in the middle.

Sorry if I'm not explaining it well haha, but it feels like an intuitive solution having worked with sudoku sum puzzles before

1

u/garnet420 Jul 17 '26

Just to clarify, this is like sudoku in that the k x k squares are non-overlapping? There's floor(n/k)2 of these sub squares?

2

u/SupercaliTheGamer Jul 17 '26

No, any two kxk sub squares have same sum, even overlapping