The magic square is a well-known grid of the numbers from 1 to 9 in which every row, column, and diagonal adds up to 15:
4 9 2
3 5 7
8 1 6
But it is also possible to create magic squares using other numbers:
24 87 45
73 52 31
59 17 80
It's also known that given just a few filled-in squares, you can determine the rest logically. For example, given the partially filled-in grid:
8 9 .
. 6 .
. 3 .
you can immediately infer that the rows, columns, and diagonals add up to 18, and so the bottom-right square is 4 and the top-right square is 1:
8 9 1
. 6 .
. 3 4
Then the right square is 13 and the bottom-left square is 11:
8 9 1
. 6 13
11 3 4
And finally, in a slightly uncouth twist, the left square is -1.
8 9 1
-1 6 13
11 3 4
But in fact, it's possible to create a set of filled-in numbers that don't have any completed rows at all and still be able to fill the rest of the numbers in:
12 .. 27
.. .. 6
.. 18 ..
This, as it turns out, has a (unique) solution of:
12 24 27
36 21 6
15 18 30
So what is the fewest number of filled-in squares that are actually possible to derive the whole square from, and what arrangement are they in? And what about the case of higher-order magic squares?