Enigmatic Code

Programming Enigma Puzzles

Enigma 243A: Square reindeer

From New Scientist #1389, 22nd December 1983 [link]

Enigma 243A

The creature pictured above is a member of the International Eccentric Association of Reindeer. As you see, his particular eccentricity is that he is square, as indeed are the Christmas presents he’s carrying — one for each member of the All-Muggleton XI. Each present is marked with a letter and the edge of each one is a (different) whole number of inches.

Originally the presents were neatly packed around the reindeer’s perimeter so as to fill up the length of each side exactly; furthermore the sum of the areas of the presents on each side was the same.

The packing has become a bit loose, but you can still see which side each present belongs to — although their sizes have been drawn very inaccurately.

To find the side-lengths of the presents (in inches), you need to solve the funny crossword-cum-crossnumber that I have drawn on the reindeer’s side. Here are the clues:

Across:
1. c
3. e
4. b
7. a
8. j

Down:
1. g
2. f
5. d
6. h
8. h
9. k

For the key to this ENIGMA, you need to know that not only is the REINDEER square in shape, but if the letters of REINDEER are replaced by certain digits, it becomes a square number. (The square root of “REINDEER” should go, in letters, on the membership card around his neck!). Using the same code, ENIGMA stands for a cubic number whose cube root is double the length of the reindeer’s side.

Finally, on the subject of deer, since it is Christmas I shall give you a present of the fact that “HIND” = 1780.

So — please put the correct 11 numbers in the present squares; the right letters on the neck label; complete the “crossword”; and enjoy a splendid Christmas.

This is the first Enigma of three that were published in the Christmas 1983 issue of New Scientist. It’s also the first Enigma (chronologically) to deviate from the standard numbering scheme.

[enigma243a] [enigma243]

Advertisements

One response to “Enigma 243A: Square reindeer

  1. Jim Randell 7 December 2014 at 7:49 am

    This Python program computes the numbers that go into the present boxes. It runs in 36ms.

    from itertools import combinations
    from enigma import irange, split, is_square, flatten, printf
    
    digits = set('0123456789')
    
    # HIND=1780
    (H, I, N, D) = '1780'
    
    # generate possible values for n, and name
    def generate():
      # ENIGMA is a 6-digit cube of 2n, where n is the side length of the reindeer
      for n in irange(24, 49):
        ENIGMA = (2 * n) ** 3
        (E, N2, I2, G, M, A) = split(ENIGMA)
        # check the letters match with what we know
        if not(N == N2 and I == I2): continue
        s = set((E, N, I, G, M, A))
        # all digits must be different, and different from H, D
        if len(s) != 6: continue
        if s.intersection((H, D)): continue
        # choose R so that REINDEER is a square
        for R in digits.difference(s, (H, D)):
          REINDEER = int(R + E + I + N + D + E + E + R)
          r = is_square(REINDEER)
          if r is None: continue
          # return (n, name, digit to letters map)
          printf("[n={n} ENIGMA={ENIGMA} REINDEER={REINDEER} name={r}]")
          yield (n, r, dict(zip((H, I, N, D, E, G, M, A, R), 'HINDEGMAR')))
    
    # translate digits to words
    def translate(n, d2l):
      return ''.join(d2l.get(d, '?') for d in str(n))
    
    # decompose n into m numbers with a sum of squares s
    def decompose(n, m, s, i=1):
      if m == 1:
        if n ** 2 == s:
          yield [n]
      else:
        for j in irange(i, n // 2):
          s2 = s - j ** 2
          if s2 < 1: break
          for x in decompose(n - j, m - 1, s2, j + 1):
            yield [j] + x
    
    for (n, name, d2l) in generate():
      printf("n={n} name={t} ({name})", t=translate(name, d2l))
    
      # the two presents on the rhs must sum to n
      for a in irange(1, (n - 1) // 2):
        b = n - a
        # and determine the sum of the squares
        s = a ** 2 + b ** 2
    
        # we need to find 3 disjoint decompositions of 33 into 3 distinct
        # numbers with the same sum of squares
        for ds in combinations(decompose(n, 3, s), 3):
          # check the decompositions are composed of distinct numbers
          if len(set(flatten(ds))) != 9: continue
        
          printf("s={s} right=({a}, {b}) rest={ds}")
    

    The program determines that (d, e) = (16, 17) and (a, b, c), (f, g, h), (i, j, k) = (1, 12, 20), (2, 10, 21), (5, 6, 22), but the actual assignments amongst these groups is not determined.

    We note on the grid that the numbers are represented with 1, 2, 3 or 4 characters. So we know at least some of the representations are other than the standard decimal representation (or the spelling out with the letter substitutions that we have already determined). And h is represented by both a 3 character clue (6 down) and a 1 character clue (8 down), so there must be multiple representation methods used in the grid.

    Considering the ways the numbers could be represented – as standard decimal, as Roman Numerals, as words, as substituted letters – we get the following possibilities (eliminating those that take more than 4 characters).

    16 = XVI = (SIXTEEN) = HA
    17 = XVII = (SEVENTEEN) = HI

    1 = I = ONE = H
    12 = XII = (TWELVE) = HE
    20 = XX = (TWENTY) = ED

    2 = II = TWO = E
    10 = X = TEN = HD
    21 = XXI = (TWENTY ONE) = EH

    5 = V = FIVE = R
    6 = VI = SIX = A
    22 = XXII = (TWENTY TWO) = EE

    First of all we look at 5 down. It is a 3 character representation of either 16 or 17. The only possibility is XVI for 16. So 3 across is a 2 character representation of 17. Which could be 17 or HI, and there’s no way to resolve the ambiguity.

    Now, (a, b, c) are a group and correspond to 7 across (??V?), 4 across (??X) and 1 across (??). The only 4 character solution matching ??V? is FIVE, so a=5. Leaving (b, c) = (6, 22) to correspond to ??X and ??. The only possible 3 character solution matching ??X is SIX, so b=6 and c=22, represented by 22 or EE in 1 across.

    6 down is a 3 character solution matching ?E?, the only possible answer is TEN. So h=10 (and 8 down is X), leaving (f, g) = (2, 21), and (i, j, k) = (1, 12, 20).

    8 across is a 3 character solution matching X?I and is a representation of 1, 12 or 20. The only possible solution is XII, so j=12, and 9 down is I, so k=1, leaving i=20 (which does not appear in the grid).

    As already noted 1 across is a 2 character representation of 22, either 22 or EE. If it were EE, then 1 down would be E, a valid 1 character representation of g=2, but 2 down would be EI which is not a valid representation of f=21 (it should be EH, EI represents 27). So we have to put 22 in 1 across. This makes 1 down 2, which is a valid 1 character representation of g=2, but 2 down is now 2I, which is also not a valid 2 character representation of f=21, although if we squint a bit (or use a font where I and 1 are indistinguishable glyphs) we could read it as 21. Or we could make it 21 and write 4 across as S1X, which with a bit of squinting looks like SIX.

    I think it’s a shame as I occurs in both Roman Numerals and the word SIX that you need to resort to tricks to conflate I and 1. (Especially as IX – a Roman Numeral – occurs within SIX (and IV in FIVE)).

    So, one way to get a unique solution to the problem is to assume that 3 across is 17 (as the letters for numbers substitution doesn’t appear in the question until after we are asked to fill out the grid), and then fill it out using a font where I and 1 are indistinguishable. Then the solution looks like this (and it is the solution given in the magazine)…

    Solution: Here is the completed puzzle:

    Enigma 243A - Solution

    For this diagram I used the font “Marker Felt”. In the grid I used “I”, but in the present boxes I used “1”, they are slightly different.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: