Enigmatic Code

Programming Enigma Puzzles

Enigma 227: Set a tease

From New Scientist #1373, 1st September 1983 [link]

Another letters for numbers problem. It may leave you at sea, for it is a tease to keep you on your toes. You see, each letter stands for a different digit each time it appears.

Enigma 227

What is a TEASE?

Note: I am waiting for a phone line to be connected at my new house, so I only have sporadic access to the internet at the moment. The latest estimate is that I’ll have a connection by the end of October 2014.



One response to “Enigma 227: Set a tease

  1. Jim Randell 6 October 2014 at 7:18 pm

    This Python program uses the SubstitutedDivision() solver from the enigma.py library to examine long division sums with the right “shape”. It runs in 390ms.

    from collections import defaultdict
    from enigma import SubstitutedDivision
    # make a sum the right "shape"
    p = SubstitutedDivision(
      '?????', '??', '????',
      [('??', '?'), None, ('???', '?'), ('??', '')]
    # make a map from the pairs such that in each (pattern, text) pair
    # the symbols in pattern correspond to different symbols in text
    def accumulate(*pairs):
      m = defaultdict(list)
      for (p, n) in pairs:
        for (k, v) in zip(p, str(n)):
          if v in m[k]: return None
      return m
    for s in p.solve():
      intermediates = p.solution_intermediates(s)
      m = accumulate(
        ('TOES', s.c),
        ('AT', s.b),
        ('TEASE', s.a),
        ('AT', intermediates[0][1]),
        ('SEA', intermediates[1][0]),
        ('SEE', intermediates[1][1]),
        ('AT', intermediates[2][0]),
        ('SO', intermediates[2][1]),
      if m is None: continue
      print(', '.join(k + ' -> ' + ''.join(m[k]) for k in sorted(m.keys())))

    Solution: TEASE = 58044.

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: