6
$\begingroup$

The puzzle is to find a Russian alphamagic square (of which there are currently none discovered).

Using programming is not necessary. If you do solve the puzzle using programming (which is much much easier than other methods), you must show the code as proof for your solution.

An alphamagic square is a magic square that remains magic when its numbers are replaced by the number of letters occurring in the name of each number. Hence, for English, 3 would be replaced by 5, the number of letters in the English word "three".

The list of the names of numbers in Russian (from 0 to 1000, "ноль" means "zero" and "тысяча" means "one thousand") is here.

Here are the objective conditions to determine the winner:

  1. The square must be as big as possible (i.e a 3✕3 square beats a 2✕2 square, etc.) 2✕2 square is worth 1 point, 3✕3 square is worth 2 points, 4✕4 square is worth 3 points, etc.
  2. The tiebreaker is the sum of all the entries in the square: the lower it is the better.

The person that has earned the most number of points (taking the tie-breaker into account) wins the competition.

NOTE: For any magic square, all of its entries must be distinct (which is not the case for Jamal Senjaya's solution, making the solution invalid).

IMPORTANT: The original link to the number names contained lots of mistakes; now the file is fully fixed. Please, download the file again.

$\endgroup$
9
  • $\begingroup$ As a reference, this puzzle has been cross-posted from Programming Puzzles and Code Golf. $\endgroup$
    – Mr. Xcoder
    Jan 14, 2018 at 10:08
  • $\begingroup$ That looks like an interesting programming puzzle. Could you please provide the Russian words in a more direct way? I guess most of us will object to sharing their e-mail in order to get the word list. $\endgroup$
    – M Oehm
    Jan 14, 2018 at 10:09
  • $\begingroup$ @MOehm I have changed the file hosting service to one that does not require your email address. $\endgroup$ Jan 14, 2018 at 10:20
  • $\begingroup$ Why not in English? in English it will be much more interesting. $\endgroup$ Jan 14, 2018 at 10:33
  • 1
    $\begingroup$ Will let you know if I see any more. Note: people who know how to code make mistakes making code too (at least I know I do!) $\endgroup$ Jan 15, 2018 at 6:59

3 Answers 3

13
$\begingroup$

 74 90 52 
 50 72 94 
 92 54 70

the alphamagic is

 15  9   12
 9   12  15 
 12  15  9

My first Answer (above), was considered false, because there are duplicates numbers in the alpha-numbers. I hope this one works

 119  213  16
 13   116  219
 216  19   113

the alphamagic is

 15 16 11
 10 14 18
 17 12 13

$\endgroup$
8
  • $\begingroup$ @AlexanderBagdasaryan If it is right please click the green tick, or at least you up vote it. :) If latter there is a better answer (bigger alphamagic-square), you can replace the green tick). $\endgroup$ Jan 14, 2018 at 13:56
  • $\begingroup$ @JamalSenjaya While the OP can still click the green checkmark, they don’t yet have the privilege to vote up posts. However, here is a +1 to appreciate your effort $\endgroup$
    – Mr. Xcoder
    Jan 14, 2018 at 14:16
  • 4
    $\begingroup$ Shouldn't a magic square consist of unique integers? If not then an infinite square of twos would be the winner. $\endgroup$ Jan 14, 2018 at 18:44
  • 1
    $\begingroup$ @AlexanderBagdasaryan : I give the new one, I hope this one works. $\endgroup$ Jan 15, 2018 at 6:30
  • 1
    $\begingroup$ Nice, looks good to me! $\endgroup$ Jan 15, 2018 at 6:57
3
$\begingroup$

By the request of OP (Alexander Bagdasaryan) I put some more answer here :

I write the answer with format like this :
[a,b,c,d,e,f,g,h,i],[j,k,l,m,n,o,p,q,r]

means :
the magic-square:      the alpha magic square
a b c                  j k l
d e f                  m n o
g h i                  p q r

Some of the solutions are :

[119,213,16,13,116,219,216,19,113],[15,16,11,10,14,18,17,12,13]
[113,219,16,19,116,213,216,13,119],[13,18,11,12,14,16,17,10,15]
[124,210,17,10,117,224,217,24,110],[17,12,10,6,13,20,16,14,9]
[120,214,17,14,117,220,217,20,114],[11,18,10,12,13,14,16,8,15]
[114,220,17,20,117,214,217,14,120],[15,14,10,8,13,18,16,12,11]
[110,224,17,24,117,210,217,10,124],[9,20,10,14,13,12,16,6,17]
[124,212,18,12,118,224,218,24,112],[17,16,12,10,15,20,18,14,13]
[112,224,18,24,118,212,218,12,124],[13,20,12,14,15,16,18,10,17]
[135,205,20,5,120,235,220,35,105],[15,10,8,4,11,18,14,12,7]
[105,235,20,35,120,205,220,5,135],[7,18,8,12,11,10,14,4,15]
[129,213,21,13,121,229,221,29,113],[17,16,12,10,15,20,18,14,13]
[126,216,21,16,121,226,221,26,116],[16,17,12,11,15,19,18,13,14]
[116,226,21,26,121,216,221,16,126],[14,19,12,13,15,17,18,11,16]
[113,229,21,29,121,213,221,13,129],[13,20,12,14,15,16,18,10,17]
[131,213,22,13,122,231,222,31,113],[15,16,11,10,14,18,17,12,13]
[127,217,22,17,122,227,222,27,117],[15,16,11,10,14,18,17,12,13]
[117,227,22,27,122,217,222,17,127],[13,18,11,12,14,16,17,10,15]
[113,231,22,31,122,213,222,13,131],[13,18,11,12,14,16,17,10,15]
[131,215,23,15,123,231,223,31,115],[15,16,11,10,14,18,17,12,13]
[115,231,23,31,123,215,223,15,131],[13,18,11,12,14,16,17,10,15]
[138,212,25,12,125,238,225,38,112],[17,16,12,10,15,20,18,14,13]
[112,238,25,38,125,212,225,12,138],[13,20,12,14,15,16,18,10,17]
[138,214,26,14,126,238,226,38,114],[17,18,13,12,16,20,19,14,15]
[134,218,26,18,126,234,226,34,118],[17,18,13,12,16,20,19,14,15]
[118,234,26,34,126,218,226,18,134],[15,20,13,14,16,18,19,12,17]
[114,238,26,38,126,214,226,14,138],[15,20,13,14,16,18,19,12,17]
[139,215,27,15,127,239,227,39,115],[17,16,12,10,15,20,18,14,13]
[115,239,27,39,127,215,227,15,139],[13,20,12,14,15,16,18,10,17]
[157,203,30,3,130,257,230,57,103],[16,9,8,3,11,19,14,13,6]
[153,207,30,7,130,253,230,53,107],[15,10,8,4,11,18,14,12,7]
[107,253,30,53,130,207,230,7,153],[7,18,8,12,11,10,14,4,15]
[103,257,30,57,130,203,230,3,157],[6,19,8,13,11,9,14,3,16]
[151,211,31,11,131,251,231,51,111],[16,17,12,11,15,19,18,13,14]
[111,251,31,51,131,211,231,11,151],[14,19,12,13,15,17,18,11,16]
[152,212,32,12,132,252,232,52,112],[15,16,11,10,14,18,17,12,13]
[146,218,32,18,132,246,232,46,118],[13,18,11,12,14,16,17,10,15]
[118,246,32,46,132,218,232,18,146],[15,16,11,10,14,18,17,12,13]
[112,252,32,52,132,212,232,12,152],[13,18,11,12,14,16,17,10,15]
[153,213,33,13,133,253,233,53,113],[15,16,11,10,14,18,17,12,13]
[113,253,33,53,133,213,233,13,153],[13,18,11,12,14,16,17,10,15]
[146,224,35,24,135,246,235,46,124],[13,20,12,14,15,16,18,10,17]
[144,226,35,26,135,244,235,44,126],[14,19,12,13,15,17,18,11,16]
[126,244,35,44,135,226,235,26,144],[16,17,12,11,15,19,18,13,14]
[124,246,35,46,135,224,235,24,146],[17,16,12,10,15,20,18,14,13]
[163,211,37,11,137,263,237,63,111],[16,17,12,11,15,19,18,13,14]
[161,213,37,13,137,261,237,61,113],[17,16,12,10,15,20,18,14,13]
[151,223,37,23,137,251,237,51,123],[16,17,12,11,15,19,18,13,14]
[148,226,37,26,137,248,237,48,126],[14,19,12,13,15,17,18,11,16]
[146,228,37,28,137,246,237,46,128],[13,20,12,14,15,16,18,10,17]
[128,246,37,46,137,228,237,28,146],[17,16,12,10,15,20,18,14,13]
[126,248,37,48,137,226,237,26,148],[16,17,12,11,15,19,18,13,14]
[123,251,37,51,137,223,237,23,151],[14,19,12,13,15,17,18,11,16]
[113,261,37,61,137,213,237,13,161],[13,20,12,14,15,16,18,10,17]
[111,263,37,63,137,211,237,11,163],[14,19,12,13,15,17,18,11,16]
[164,214,39,14,139,264,239,64,114],[19,18,14,12,17,22,20,16,15]
[114,264,39,64,139,214,239,14,164],[15,22,14,16,17,18,20,12,19]
[173,215,44,15,144,273,244,73,115],[15,16,11,10,14,18,17,12,13]
[115,273,44,73,144,215,244,15,173],[13,18,11,12,14,16,17,10,15]
[183,207,45,7,145,283,245,83,107],[17,10,9,4,12,20,15,14,7]
[160,230,45,30,145,260,245,60,130],[13,14,9,8,12,16,15,10,11]
[130,260,45,60,145,230,245,30,160],[11,16,9,10,12,14,15,8,13]
[107,283,45,83,145,207,245,7,183],[7,20,9,14,12,10,15,4,17]
[189,203,46,3,146,289,246,89,103],[20,9,10,3,13,23,16,17,6]
[183,209,46,9,146,283,246,83,109],[17,12,10,6,13,20,16,14,9]
[182,210,46,10,146,282,246,82,110],[17,12,10,6,13,20,16,14,9]
[172,220,46,20,146,272,246,72,120],[15,14,10,8,13,18,16,12,11]
[170,222,46,22,146,270,246,70,122],[12,17,10,11,13,15,16,9,14]
[122,270,46,70,146,222,246,22,170],[14,15,10,9,13,17,16,11,12]
[120,272,46,72,146,220,246,20,172],[11,18,10,12,13,14,16,8,15]
[110,282,46,82,146,210,246,10,182],[9,20,10,14,13,12,16,6,17]
[109,283,46,83,146,209,246,9,183],[9,20,10,14,13,12,16,6,17]
[103,289,46,89,146,203,246,3,189],[6,23,10,17,13,9,16,3,20]
[186,210,48,10,148,286,248,86,110],[19,12,11,6,14,22,17,16,9]
[170,226,48,26,148,270,248,70,126],[12,19,11,13,14,15,17,9,16]
[155,241,48,41,148,255,248,55,141],[16,15,11,9,14,19,17,13,12]
[151,245,48,45,148,251,248,51,145],[16,15,11,9,14,19,17,13,12]
[145,251,48,51,148,245,248,45,151],[12,19,11,13,14,15,17,9,16]
[141,255,48,55,148,241,248,41,155],[12,19,11,13,14,15,17,9,16]
[126,270,48,70,148,226,248,26,170],[16,15,11,9,14,19,17,13,12]
[110,286,48,86,148,210,248,10,186],[9,22,11,16,14,12,17,6,19]
[157,241,49,41,149,257,249,57,141],[16,15,11,9,14,19,17,13,12]
[152,246,49,46,149,252,249,52,146],[15,16,11,10,14,18,17,12,13]
[151,247,49,47,149,251,249,51,147],[16,15,11,9,14,19,17,13,12]
[147,251,49,51,149,247,249,47,151],[12,19,11,13,14,15,17,9,16]
[146,252,49,52,149,246,249,46,152],[13,18,11,12,14,16,17,10,15]
[141,257,49,57,149,241,249,41,157],[12,19,11,13,14,15,17,9,16]
[183,219,51,19,151,283,251,83,119],[17,18,13,12,16,20,19,14,15]
[165,251,37,23,151,279,265,51,137],[17,19,12,11,16,21,20,13,15]
[179,223,51,23,151,279,251,79,123],[18,17,13,11,16,21,19,15,14]
[173,229,51,29,151,273,251,73,129],[15,20,13,14,16,18,19,12,17]
[167,235,51,35,151,267,251,67,135],[17,18,13,12,16,20,19,14,15]
[165,237,51,37,151,265,251,65,137],[17,18,13,12,16,20,19,14,15]
[158,244,51,44,151,258,251,58,144],[18,17,13,11,16,21,19,15,14]
[154,248,51,48,151,254,251,54,148],[18,17,13,11,16,21,19,15,14]
[137,279,37,51,151,251,265,23,165],[15,21,12,13,16,19,20,11,17]
[148,254,51,54,151,248,251,48,154],[14,21,13,15,16,17,19,11,18]
[144,258,51,58,151,244,251,44,158],[14,21,13,15,16,17,19,11,18]
[137,265,51,65,151,237,251,37,165],[15,20,13,14,16,18,19,12,17]
[135,267,51,67,151,235,251,35,167],[15,20,13,14,16,18,19,12,17]
[129,273,51,73,151,229,251,29,173],[17,18,13,12,16,20,19,14,15]
[123,279,51,79,151,223,251,23,179],[14,21,13,15,16,17,19,11,18]
[119,283,51,83,151,219,251,19,183],[15,20,13,14,16,18,19,12,17]
[171,233,52,33,152,271,252,71,133],[16,17,12,11,15,19,18,13,14]
[155,249,52,49,152,255,252,55,149],[16,17,12,11,15,19,18,13,14]
[149,255,52,55,152,249,252,49,155],[14,19,12,13,15,17,18,11,16]
[133,271,52,71,152,233,252,33,171],[14,19,12,13,15,17,18,11,16]
[195,211,53,11,153,295,253,95,111],[16,17,12,11,15,19,18,13,14]
[186,220,53,20,153,286,253,86,120],[19,14,12,8,15,22,18,16,11]
[180,226,53,26,153,280,253,80,126],[14,19,12,13,15,17,18,11,16]
[164,242,53,42,153,264,253,64,142],[19,14,12,8,15,22,18,16,11]
[162,244,53,44,153,262,253,62,144],[16,17,12,11,15,19,18,13,14]
[157,249,53,49,153,257,253,57,149],[16,17,12,11,15,19,18,13,14]
[149,257,53,57,153,249,253,49,157],[14,19,12,13,15,17,18,11,16]
[144,262,53,62,153,244,253,44,162],[14,19,12,13,15,17,18,11,16]
[142,264,53,64,153,242,253,42,164],[11,22,12,16,15,14,18,8,19]
[126,280,53,80,153,226,253,26,180],[16,17,12,11,15,19,18,13,14]
[120,286,53,86,153,220,253,20,186],[11,22,12,16,15,14,18,8,19]
[111,295,53,95,153,211,253,11,195],[14,19,12,13,15,17,18,11,16]
[169,239,54,39,154,269,254,69,139],[19,20,15,14,18,22,21,16,17]
[139,269,54,69,154,239,254,39,169],[17,22,15,16,18,20,21,14,19]
[199,211,55,11,155,299,255,99,111],[18,17,13,11,16,21,19,15,14]
[196,214,55,14,155,296,255,96,114],[17,18,13,12,16,20,19,14,15]
[194,216,55,16,155,294,255,94,116],[18,17,13,11,16,21,19,15,14]
[187,223,55,23,155,287,255,87,123],[18,17,13,11,16,21,19,15,14]
[183,227,55,27,155,283,255,83,127],[17,18,13,12,16,20,19,14,15]
[178,232,55,32,155,278,255,78,132],[18,17,13,11,16,21,19,15,14]
[172,238,55,38,155,272,255,72,138],[15,20,13,14,16,18,19,12,17]
[166,244,55,44,155,266,255,66,144],[18,17,13,11,16,21,19,15,14]
[144,266,55,66,155,244,255,44,166],[14,21,13,15,16,17,19,11,18]
[138,272,55,72,155,238,255,38,172],[17,18,13,12,16,20,19,14,15]
[132,278,55,78,155,232,255,32,178],[14,21,13,15,16,17,19,11,18]
[127,283,55,83,155,227,255,27,183],[15,20,13,14,16,18,19,12,17]
[123,287,55,87,155,223,255,23,187],[14,21,13,15,16,17,19,11,18]
[116,294,55,94,155,216,255,16,194],[14,21,13,15,16,17,19,11,18]
[114,296,55,96,155,214,255,14,196],[15,20,13,14,16,18,19,12,17]
[111,299,55,99,155,211,255,11,199],[14,21,13,15,16,17,19,11,18]
[198,216,57,16,157,298,257,98,116],[18,17,13,11,16,21,19,15,14]
[196,218,57,18,157,296,257,96,118],[17,18,13,12,16,20,19,14,15]
[183,231,57,31,157,283,257,83,131],[17,18,13,12,16,20,19,14,15]
[181,233,57,33,157,281,257,81,133],[18,17,13,11,16,21,19,15,14]
[166,248,57,48,157,266,257,66,148],[18,17,13,11,16,21,19,15,14]
[161,253,57,53,157,261,257,61,153],[17,18,13,12,16,20,19,14,15]
[153,261,57,61,157,253,257,53,161],[15,20,13,14,16,18,19,12,17]
[148,266,57,66,157,248,257,48,166],[14,21,13,15,16,17,19,11,18]
[133,281,57,81,157,233,257,33,181],[14,21,13,15,16,17,19,11,18]
[131,283,57,83,157,231,257,31,183],[15,20,13,14,16,18,19,12,17]
[118,296,57,96,157,218,257,18,196],[15,20,13,14,16,18,19,12,17]
[116,298,57,98,157,216,257,16,198],[14,21,13,15,16,17,19,11,18]
[169,253,61,53,161,269,261,69,153],[19,18,14,12,17,22,20,16,15]
[163,259,61,59,161,263,261,63,159],[16,21,14,15,17,19,20,13,18]
[159,263,61,63,161,259,261,59,163],[18,19,14,13,17,21,20,15,16]
[153,269,61,69,161,253,261,53,169],[15,22,14,16,17,18,20,12,19]
[194,232,63,32,163,294,263,94,132],[18,17,13,11,16,21,19,15,14]
[192,234,63,34,163,292,263,92,134],[15,20,13,14,16,18,19,12,17]
[178,248,63,48,163,278,263,78,148],[18,17,13,11,16,21,19,15,14]
[148,278,63,78,163,248,263,48,178],[14,21,13,15,16,17,19,11,18]
[134,292,63,92,163,234,263,34,192],[17,18,13,12,16,20,19,14,15]
[132,294,63,94,163,232,263,32,194],[14,21,13,15,16,17,19,11,18]
[194,236,65,36,165,294,265,94,136],[18,19,14,13,17,21,20,15,16]

This is my code in Haskell, but I omit the numbers list length (pjg x = y) to make the listed code not too long, after adding the numbers list your self, just run jaw from the main prompt. (sorry if I write it awfully :), it the result come out quite fast). I limited the numbers from 1 to 300.

import Data.List


ak = [1..300]
jaw = [[[a,b,c,d,e,f,g,h,i],[pjg a,pjg b,pjg c,pjg d,pjg e,pjg f,pjg g,pjg h,pjg i]]|
       e <- ak, let s1 = e*3, let s2 = (pjg e) * 3, 
       d <- ak \\ [e], 
       let f = s1 - (e+d), f > d, f >= 0, f < 1001, sum [pjg d, pjg e, pjg f] == s2,
       (length.nub.sort $ [pjg d, pjg e, pjg f]) == 3,
       a <- ak \\ [e,d,f], elem (pjg a) [pjg d, pjg e, pjg f] == False,
       let g = s1 - (a+d), g > a, g >= 0, g < 1001, (length.nub.sort $ [a,d,e,f,g]) == 5,
          sum [pjg a, pjg d, pjg g] == s2, elem (pjg g) [pjg a, pjg d, pjg e, pjg f] == False,

       b <- ak \\ [a,d,e,f,g], let c = s1 - (a+b), c >= 0, c < 1001, sum [pjg a, pjg b, pjg c] == s2,
       let h = s1 - (b+e), h >= 0, h < 1001, sum [pjg b, pjg e, pjg h] == s2,
       let i = s1 - (c+f), i >= 0, i < 1001, sum [pjg c, pjg f, pjg i] == s2, sum [g,h,i] == s1, sum [pjg g, pjg h, pjg i] == s2,
       sum [a,e,i] == s1, sum [g,e,c] == s1,
       sum [pjg a,pjg e,pjg i] == s2, sum [pjg g,pjg e,pjg c] == s2,
       (length.nub.sort $ [a,b,c,d,e,f,g,h,i]) == 9,
       (length.nub.sort $ [pjg a,pjg b,pjg c,pjg d,pjg e,pjg f,pjg g,pjg h,pjg i]) == 9,
       True] 

-- edit this for the numbers-list-length 
pjg 0 = 4
pjg 1 = 4
pjg 3 = 3 
...
pjg 1000 = 6
$\endgroup$
1
  • $\begingroup$ Words can't describe how thankful I am for your fabulous work. Thank you so much! $\endgroup$ Jan 15, 2018 at 12:46
1
$\begingroup$

I also wrote code to find three-by-three magic squares, mine is in Python and is probably easier for many to understand - it uses Édouard Lucas's method to create the distinct* number squares, then checks if the word-length one is also magic.
You can run it here.
(if you don't want to wait for the 60 second timeout before it flushes output to the screen, click the "play" button a second time)
If it completes (it has to be locally as it takes longer than 60s) it outputs all 150 distinct* 3x3 alphamagic squares using the Russian word lengths
(to output English ones instead change "Russian" in the very last line of the code to "English")

The word lengths are also created programmatically (see getRussianNumberlengthsZeroTo1000()); I don't think I made any errors with that but I can't actually access the word length file at this machine (will check it at some point though).

There may be some four-by-four ones, but without higher numbers than 1000 there can be no 5-by-five -- word lengths of three through twenty-six inclusive are present, but that's only 24 values, while 25 are needed.

* each square has seven other equivalent versions by reflection and rotation.

SLICE_PARAMS = ((0, 3, 1), (3, 6, 1), (6, 9, 1), (0, 9, 3), (1, 9, 3), (2, 9, 3), (0, 9, 4))

def printRussianAlphamagicSquares():
    count = 0
    for magicSquare, numberWordLengthSquare in findAlphamagicSquares(getRussianNumberlengthsZeroTo1000()):
        fieldLength = len(str(max(magicSquare + numberWordLengthSquare)))
        printSquare(magicSquare, header="The magic Square:", footer="...has word length magic square:",
                    fieldLengthOverride=fieldLength)
        printSquare(numberWordLengthSquare)
        count += 1
    print("\n\nFound a total of {} alphamagic squares".format(count))

def findAlphamagicSquares(numberWordLengths):
    for magicSquare in iterSqSubset(range(len(numberWordLengths))):
        numberWordLengthSquare = tuple(numberWordLengths[value] for value in magicSquare)
        if isMagicSquare(numberWordLengthSquare):
            yield magicSquare, numberWordLengthSquare

def isMagicSquare(square):
    if len(set(square)) < len(square):
        return False
    antiDiagonalSum = sum(square[2:7:2])
    return all(sum(square[start:stop:step]) == antiDiagonalSum for (start, stop, step) in SLICE_PARAMS)

def iterSq(offset=0):
    '''This is Édouard Lucas's method to generate magic squares
       offset adds a value to all entries of each square'''
    b, c, = 3, 5
    while 1:
        a = 1
        while a < b < c - a:
            if b != 2 * a:
                p, m, x = a + b, a - b, c + offset
                yield (x - b, x + p, x - a, x - m, x, x + m, x + a, x - p, x + b)
            a += 1
        b += 1
        if c == b:
            b = 3
            c += 1

def iterSqSubset(validEntries):
    '''This only yields those magic squares with values in the given set, then stops.'''
    ve = set(validEntries)
    lowerBound = min(ve)
    upperBound = max(ve)
    for sq in iterSq(lowerBound - 1):
        if all(v in ve for v in sq):
            yield sq
        elif min(sq) >= upperBound:
            break

def getEnglishNumberlengthsZeroTo1000():
    u = (0, 3, 3, 5, 4, 4, 3, 5, 5, 4)
    n = (3, 6, 6, 8, 8, 7, 7, 9, 8, 8)
    t = (6, 6, 5, 5, 5, 7, 6, 6)
    r = []
    h = 7
    for hs in range(10):
        hx = u[hs] + h * (hs > 0)
        r.extend([hx + v for v in u])
        r.extend([hx + v for v in n])
        for ts in t:
            r.extend([hx + ts + v for v in u])
    r[0] = 4
    r.append(11)
    return r

def getRussianNumberlengthsZeroTo1000():
    u = (0, 4, 3, 3, 6, 4, 5, 4, 6, 6)
    n = (6, 11, 10, 10, 12, 10, 11, 10, 12, 12)
    t = (8, 8, 5, 9, 10, 9, 11, 9)
    r = []
    h = 7
    for hs in range(10):
        hx = u[hs] * (hs > 1) + 3 * (hs > 0)
        r.extend([hx + v for v in u])
        r.extend([hx + v for v in n])
        for ts in t:
            r.extend([hx + ts + v for v in u])
    r[0] = 4
    r.append(6)
    return r

def printSquare(square, header=None, footer=None, fieldLengthOverride=None):
    if header:
        print(header)
    if fieldLengthOverride is None:
        fieldLength = len(str(max(square)))
    else:
        fieldLength = fieldLengthOverride
    for start, stop in ((0, 3), (3, 6), (6, 9)):
        print(' '.join('{0:{l}}'.format(v, l=fieldLength) for v in square[start:stop]))
    if footer:
        print(footer)

if __name__ == "__main__":
    printRussianAlphamagicSquares()
$\endgroup$
6
  • $\begingroup$ Are you saying that if we want to find a 4 by 4 Russian alphamagic square, we must go beyond 1000? How far should we go? I can extend the list of the number names if needed. $\endgroup$ Jan 16, 2018 at 4:43
  • $\begingroup$ @AlexanderBagdasaryan for a 5 by 5 we'd need one more number length available. 4 by 4 may well be possible already, I haven't looked. $\endgroup$ Jan 16, 2018 at 7:15
  • $\begingroup$ I would appreciate it if you looked into possible 4 by 4 ones. $\endgroup$ Jan 16, 2018 at 14:22
  • $\begingroup$ tinyurl.com/ya2ndqgd - 2 errors. I don't know Russian so I'm not sure which one is correct. $\endgroup$
    – user44427
    Jan 17, 2018 at 4:53
  • $\begingroup$ @user202729 Ah 1000 should be length 6 (copy-paste from English function), I commented about 92 (I'm pretty sure that reads 192). FWIW changing 1000 from 11 to 6 has not affected the results. $\endgroup$ Jan 17, 2018 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.