1266 - Magic Square


Difficulty : easy

Solution Description :

Magic Square Problem

The Siamese method, or De la Loubère method, is a simple method to construct any size of n-odd magic squares.

Starting from the central box of the first row with the number 1 (or the first number of any arithmetic progression), the fundamental movement for filling the boxes is diagonally up and right (), one step at a time. When a move would leave the square, it is wrapped around to the last row or first column, respectively.

If a filled box is encountered, one moves vertically down one box () instead, then continuing as before

Order-3 magic squares

step 1
1
.
.
step 2
1
.
2
step 3
1
3
2
step 4
1
3
42
step 5
16
35
42
step 6
16
357
42
step 7
816
357
42
step 8
816
357
492

Order-5 magic squares

Step 1
1
.
.
.
.
Step 2
1
.
.
.3
.2
Step 3
1
5
4.
3
2
Step 4
18
57
46.
3
2
Step 5
1815
5714
4613
10123
1129
Step 6
17241815
23571416
46132022
101219213
11182529
-adopt from Wikipedia