1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# Since there are eleven visible digits for four different length # squares, the lengths must be 1, 2, 3 and 5 digits; the '10' digit # sequence must occur in the 5 digit square since it doesn't appear # in any 1, 2 or 3 digit square. # The arrangement is a one high 2 by 5 rectangular block with single # digit cube faces (d), the 10 cube face and blank cube faces (s) in # one of these two sequencees reading left to right around the faces # # (s d 10 d d) (s d) (s d d d s) (d d) # (s d d 10 d) (s d) (s d d d s) (d d) # consider all five digit squares for d in (str(x * x) for x in range(100, 317)): # find those that contain the '10' sequence, at most two # '1's and at most one of all other digits if ('10' in d and d.count('1') <= 2 and all(d.count(c) <= 1 for c in '234567890')): # now consider all combinations of 1, 2 and 3 digit squares for a in ('149'): for b in (str(x * x) for x in range(4, 10)): for c in (str(x * x) for x in range(11, 32)): # find a combination of squares with one of each digit # from two to nine inclusive together with two ones s = a + b + c + d if s.count('1') == 2 and all(s.count(c) == 1 for c in '234567890'): print(a, b, c, d) |