Introduction
For 1/19 as generator of the 18x18 magic square
see here. The 18 rows, 18 columns and 2 diagonals all add up to 81. Each row and each column contains one 0 and one 9, and each other digit twice. In this post we implement this magic square, coloured, in GeoGebra.
The digits
- digits01 = {0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1}
- digits02 = {1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2}
- digits03 = {1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3}
- digits04 = {2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4}
- digits05 = {2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5}
- digits06 = {3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6}
- digits07 = {3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7}
- digits08 = {4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8}
- digits09 = {4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9}
- digits10 = {5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0}
- digits11 = {5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1}
- digits12 = {6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2}
- digits13 = {6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3}
- digits14 = {7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4}
- digits15 = {7, 8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5}
- digits16 = {8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8, 9, 4, 7, 3, 6}
- digits17 = {8, 9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7}
- digits18 = {9, 4, 7, 3, 6, 8, 4, 2, 1, 0, 5, 2, 6, 3, 1, 5, 7, 8}
The list of all 324 digits {0, 5, 2, ..., 5, 7, 8}, from the first in digits01 to the last in digits18, is obtained in digits below.
- digits00={digits01, digits02, digits03, digits04, digits05, digits06, digits07, digits08,d igits09,d igits10, digits11, digits12, digits13, digits14, digits15, digits16, digits17, digits18}
- digits=flatten(digits00)
The squares
- to18=Sequence(18)
- h01=(to18, 1) etc h18=(to18, 18)
- coor00={h18, h17, h16, h15, h14, h13, h12, h11, h10, h09, h08, h07, h06, h05, h04, h03, h02, h01}
- coor=flatten(coor00)
squares is the list of the 324 unit squares centered at the coordinates in coor.
- coorlu=coor + (-0.5, -0.5)
- coorru=coor + (0.5, -0.5)
- squares=Sequence(Polygon(coorlu(k), coorru(k), 4), k, 1, 18 * 18)
![]() |
squares and coor |
Squares coloured per digit
- is0=KeepIf(digits(k) ≟ 0, k, 18*18)
- squares0=Sequence(squares(is0(k)), k, 1, Length(is0))
Doing the same for 1,2,...,9 one obtains the ten-colour square shown above. To separate the squares, a black grid has been added:
- hori=Sequence(Segment((0.5, k - 0.5), (18.5, k - 0.5)), k, 1, 19)
- verti=Sequence(Segment((k - 0.5, 0.5), (k - 0.5, 18.5)), k, 1, 19)