About Magic Square
The three by three magic square is among the oldest number puzzles known. It appears in Chinese tradition as the Lo Shu, said to have been seen on the shell of a turtle, and it has fascinated people for more than two thousand years. All eight lines through the grid must give the same total.
How it works
The total has to be 15. The numbers 1 to 9 add up to 45, and they are shared across three rows, so each row gets a third.
Row totals appear on the right, column totals along the bottom, and the corner shows the diagonal that runs from top left to bottom right. The other diagonal is given in the status line, with a count of how many of the eight lines are correct.
Solving it by reasoning
You can stumble on the answer by swapping, but it is far more satisfying to work it out.
Start with the centre. The middle square belongs to four lines: one row, one column and both diagonals. Only one number can cope with that, and it is 5, the middle of the range. Put it there first.
Next, the corners. Each corner sits on three lines, each edge square on two. If you list the ways of making 15 with three different numbers, the even numbers 2, 4, 6 and 8 each appear in three of them, and the odd numbers 1, 3, 7 and 9 in only two. So the even numbers go in the corners and the odd ones on the edges.
Finally, pairs. Opposite squares must add up to 10, because they share a line with the 5. Put 2 opposite 8 and 4 opposite 6, and the edges fill themselves in.
There is really only one solution, turned and mirrored eight ways. Few HTML5 games let you reach a result that old with your own reasoning.