Automatic Construction
Previus Credits Index Next

Now I build the programs that automatically construct a prime square of order 12, 15, 17 and 22. But how one of them works?

  1. It generates a random square, so we have all the rows and columns at the same order of distance to the magic state.
  2. It searches all the value to changes (all combination) from second row to first one (in the same columns) that make the first row magic.
  3. It searches now for third columns to second for making the second magic.
  4. It goes ahead with the same scheme until the precedent of the last.
  5. If not all the rows are become magic (because no right changes was found), it repeats the procedure using 1 and 3 rows , 2 and 4 ...
  6. If there's rows still not magic, we go to point 1 because we have spend too much time for this square.
  7. It rotates the square and repeat the procedure as in point 2 (we now operates in the columns, because the rotation makes columns to become rows)
  8. It applies the automatic procedure that make the diagonals to the magic state
I want to remember you how the procedure of point 8 works:
it chooses one value for columns at different rows until the chosen values reach the magic state. If we changes the rows for making the choose value to be in the column, we make that column magic. This step is repeated until the other diagonal become automatically magic, but the choose value are taken with other combination.

I generate easy the 12, 15 and 17 order, but for order 22 I can't find solution (after 4 hour of calculation). So I speed up the program coding it more reliable and I find the 22 order in 2 hour with the 286. The 12 order is find out at the average rate of 1 in 2 minutes.

These are the first squares that I automatically found for order 12, 15, 17 and 22:

                        Prime Magic Square of order 12

    53  103  193  239  769  719  167  383  503  107  467  811
   421   43   17  349  163  653  571  233  317  499  727  521
   647  773  223   41  487  139  821  359  131  109  491  293
   683  557  181  113  593  577  541   29  443  307  389  101
   733  353  401  419  619  751  283   23   79  601   61  191
     1  523  379  211   31  599    3  509  661  691  709  197
   229  827  643  673  613   37   97  397   59  457  151  331
    67   19  431  269  641  281   47  617  311  823  251  757
   449   73   71  607  179  373  587  677  701  347  439   11
   569  563  547  659  157  137  809  271   89  227  337  149
   463  367  797  173  257    7  127  739  433  263  479  409
   199  313  631  761    5  241  461  277  787   83   13  743

                        Prime Magic Square of order 15

  1193  197  359  569  661  619 1181  853 1237  521  523  499  643  577    3
     1  601  983 1123  937 1171  919  367  127 1039 1259   89  419  109  491
   947 1307  311  277   59  877   47 1151  151  409  347  701  613 1321 1117
   487   53   31  503  677 1277  251 1289 1319  557 1013  131  337 1427  283
   191 1069  593   13  991  659  281  199 1231  863 1301 1229  397  599   19
  1031 1187  107  859  727  349  373  827  269  313   97  709  839  971  977
   563  953  829  571  769 1109  467 1303  653 1201   41  149  641  163  223
   743  383 1399   71  733 1153  881  509  157  461   83  401  587  911 1163
  1049  929  353 1249  433  179  331  293 1327  241  307 1217   23 1021  683
  1019  257  113  103  541 1367  101 1213  547  229  691  887  821  463 1283
   631 1381  181  941  857  173 1051    5   79 1033  809 1409  797   61  227
   443  167 1103 1361  421   11 1223  607  479  457  787  997 1279   37  263
    43  317 1093 1129 1423   67  823   29  751 1063  907  647  137  449  757
  1061  761 1297  193   17    7  739  719  211 1009  379  139 1291  439 1373
   233   73  883  673  389  617  967  271 1097  239 1091  431  811 1087  773

                        Prime Magic Square of order 17

  1213  563 1801  521 1481  953  227  757 1019  419  113 1093  223 1009 1619  229 1451
  1289 1399  769 1187   47   23 1471 1453 1867  257  761  523   61  409   31 1543 1601
  1579 1279  599 1201 1153 1553  613  191  617  167 1609 1423 1523  967   71   37  109
  1361 1021    5   67  439 1447  457  881 1669  607  449 1567 1229 1571  751 1031  139
   977  103   19  677 1823 1429 1787 1231 1693  619   29   73 1193  307  127 1741  863
    59   11 1091  313 1597 1297 1039 1163 1061 1181  743  601  593 1699 1033  827  383
   397 1249  269  199 1303  887  719  673  421 1171  971 1367 1069  181 1583  509 1723
   809 1559  709 1237  547 1789 1459  241  571 1483  661  983  541  641  557  131  773
    13 1831 1087 1783  467  359  739  163  151 1777 1109  379  683  907 1663  937  643
   653  821 1129 1217   17  311 1879  487    7 1753 1487  839 1493 1733  233  283  349
     1 1489 1759 1613  251    3  107 1097 1013  877  691  263   97  997 1499 1871 1063
   157  947  179  701 1627  367 1223 1861  991   53 1667  859  193  373 1873  293 1327
   647   43 1123 1291  503 1117  431 1847  911  733 1439  211 1301  659 1811  347  277
  1721  823  433  317 1511  271  239  337  491 1051  353 1433 1709  101  727 1427 1747
   857  137 1637   79 1259 1049  797  929   41  853  331 1277 1103 1697  443 1283  919
  1549  829 1621  631   89 1373  197  811  787 1607  401 1321 1531  499  389  883  173
  1409  587  461 1657  577  463 1307  569 1381   83 1877  479  149  941  281 1319 1151

                        Prime Magic Square of order 22

  1031  283    3  613 1933 3001 1069 1489 2647 3331 1019 2551  439 2917 2411 3011   61 3121  1097 2633  199   67
   877   89 1061 2837 2063  809 1429  853  317 2333 2687 2467 2591 2693 1867 2137  863 1123  1847 1367 2437  179
   251 1741 2897 2269 1697  353  811 3461 2143 1699 1579  383  487  719 3391 2237  461 1481  2719 1423  347 2377
  1303 3137   23 2447  313 2309 2593 1459 2971 2389   41 1993  751  379 1327 1637 2213 1487  1973 3359  691  131
   953  673 1493 2141 1399 1627  727  521 3329 2087 3079 1543   43  523 2677 1499 3373  761  1103 1091 2131 2153
  1789 1433 2531 1723 1297 2399  193 3169  103 3407 2243  967 1901  367  827 1753 1471 2819  1217  647 1553 1117
  2393  191 1013 3323 1721 2957 1321 2083 1093 1607  739 1021 1129  113 1087 2099 3221 2777   197  991 2339 1511
  2749  661  617  457 1439 3037 1571  641 2753  601  157 2657  211 2797 1619 1289 2711 1951  3301  977  997 1733
   919  983 3413 1361 1039 2477  499    1  883  419 3347 2239 2579 3209 1301   17 2113 3257   569 2801   47 1453
  2609 2621 2861  337   19   79 1567 2857   37 2053 2909 2089 1231  599   73 1913 2543 3083  1213  887 1523 1823
  2357 3191 3119  101 3313  163  907 1151 1811    5 1979 1181  227  797 3019  857   11  311  2939 1279 3041 3167
  1889 2297 2557  571 2221 3109 1657  911 1283 1907  929  829 2843  509  389 1451  151  173  2731 3343  373 2803
  2729 1319  587  241 2663 1549 1931 2617 1787 3307  443 2927 1223  401 1277   97 2903  449   271 1987 3449  769
  1879 2011  937 1153  683   71 3217 2111 2549  137 1051  479 2879 2207  331 3299 2833 1613  1693 1063 2423  307
   941 2503 1801 2027  109  773 2699  433  631 2791  257  127 3187 3253 2081 1427 2689 2707   619  467 1621 1783
   593 1259  149  293   13  701 2069 3061 2953 2251 2351  563 2521 1777 1873 2851  971  659  1009 2683 2287 2039
   463 1877 2281 1049 2999  409 3259 2381  269  491 1609 3457  349 3163  743 1109 2441 2203  2473  947  277  677
  1249 2767 2383 3023  757 3271 1583  181 3361  733  547 3049 2293 1759  653  233  859  229  3433 1949    7  607
  2713   59  167 3089 1171 2273 1669 2887   83  787 1229  643 3181 1307 1373 2179  577  281   821 3371 3319 1747
  1381 3251 2017 1193 2347 1163 1601 1597  431  823 2789 1237  503 2129 2267 2161 1201  223  2003  239 1831 2539
  2671  709   53 2969 2341 1999 1997   29 3229  359 1483 2417 1291 1861 2029  139  839 1559  1667  881 1663 2741
  1187 1871 2963 1709 3389  397  557 1033  263 1409 2459  107 3067 1447 2311 1531  421  2659   31  541 2371 3203
And for the upper order? I think that with a 286 is impossible, so I take another problem...

 
Top
Magic
Magic Square Research Tognon Stefano Research