Enigmatic Code

Programming Enigma Puzzles

Enigma 213: Enigma’s square

From New Scientist #1359, 26th May 1983 [link]


Usual letters-for-digits rules. The same letter is the same digit, different letters are different digits, throughout.

What (in letters) is the result of multiplying YE by EIYIELIGMI?

[Note: I am in the process of moving house, so my time and internet connectivity will be constrained over the next couple of weeks. I’ll keep posting puzzles when I can. Normal service will be resumed when the internet comes to Wales.]


5 responses to “Enigma 213: Enigma’s square

  1. Jim Randell 10 August 2014 at 7:29 am

    This Python program uses some useful routines from the enigma.py library. It runs in 43ms.

    from itertools import permutations
    from enigma import irange, nconcat, split, is_square, printf
    # choose digits for Y, S, E
    for (Y, S, E) in permutations(irange(0, 9), 3):
      # ignore leading zeros
      if Y == 0: continue
      YSSE = nconcat(Y, S, S, E)
      # check ENIGMAS is 7-digit, and matches E and S
      ENIGMAS = YSSE ** 2
      if ENIGMAS < 1000000 or ENIGMAS > 9999999: continue
      (E1, N, I, G, M, A, S1) = split(ENIGMAS, int)
      if E1 != E or S1 != S: continue
      # SLA ^ 2 = ENIGMA
      SLA = is_square(ENIGMAS // 10)
      if SLA is None: continue
      # check S and A match
      (S1, L, A1) = split(SLA, int)
      if S1 != S or A1 != A: continue
      # map digits to letters
      d = dict((x, y) for (x, y) in zip((Y, S, E, N, I, G, M, A, L), 'YSENIGMAL'))
      # check all the letters are distinct
      if len(d) != 9: continue
      # calculate YE * EIYIELIGMI as digits and letters
      n = nconcat(Y, E) * nconcat(E, I, Y, I, E, L, I, G, M, I)
      r = ''.join(d.get(x, '?') for x in split(n, int))
      # print the result
      printf("{r}={n} [YSSE={YSSE} ENIGMAS={ENIGMAS} SLA={SLA}]")

    Solution: The result is MEANINGLESS.

    • geoffrounce 11 August 2014 at 9:31 am

      Another solution:

      from itertools import permutations
      for p in permutations ('0123456789', 9):
        s,l,a,e,n,i,g,m,y = p
        # check no leading digits are zero in two equations 
        if all( x != '0' for x in (s,e,y)):
          sla = int(s + l + a)
          enigma = int(e + n + i + g + m + a)
          if sla * sla == enigma:
            enigmas = int(e + n + i + g + m + a + s)
            ysse = int(y + s + s + e)
            if ysse * ysse == enigmas:
              ye = int(y + e) 
              eiyieligmi = int(e + i + y + i + e + l + i + g + m + i)
              result = ye * eiyieligmi  
              str_result = str (result)
              # get result of multiplication in words
              ndict = dict(zip(p, 'SLAENIGMY'))
              word = ''.join(ndict[x] for x in str_result)
              print('Multiplying YE by EIYIELIGMI gives ',word)
              print('Or', result, ' as a number')
  2. Tessa Fullwood 10 August 2014 at 1:01 pm

    I see you are moving. Good wishes with that. The internet has reached Wales in Alaska! By now!

  3. Jim Randell 11 November 2017 at 10:05 am

    Here’s a solution using the [[ SubstitutedExpression() ]] solver from the enigma.py library to solve the alphametic problem. We then use the solution to substitute digits for letters in the answer.

    This Python program runs in 66ms.

    Run: [ @repl.it ]

    from enigma import SubstitutedExpression, nsplit, join, printf
    # make the alphametic puzzle
    p = SubstitutedExpression(
      [ "SLA ** 2 = ENIGMA", "YSSE ** 2 = ENIGMAS" ],
      answer="YE * EIYIELIGMI",
    # and solve it
    for (s, ans) in p.solve():
      # reverse the solution mapping
      d = dict((d, s) for (s, d) in s.items())
      # and map the digits in the answer to symbols
      answer = join(d.get(x, '?') for x in nsplit(ans))
      # output the answer
      printf("answer = {answer} [{ans}]")

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: