Enigmatic Code

Programming Enigma Puzzles

Enigma 1581: Daley’s Gold

From New Scientist #2746, 6th February 2010 [link]

In July 2009, 16 months after winning the individual diving gold medal from the 10-metre platform board at the European Championships at the age of 13, Thomas Daley won the gold medal at the World Championships. So it is fitting that I can offer this puzzle:

Enigma 1581

In this subtraction, digits have been consistently replaced by letters, with different letters representing different digits. No number starts with a zero. Since there are 11 different letters, everything is in base 11 – use the digits 0 to 9 as normal and add a symbol of your choice for the extra digit.

Please send in the 6-digit number (still in base 11) that is represented by THOMAS.

[enigma1581]

Advertisements

2 responses to “Enigma 1581: Daley’s Gold

  1. jimrandell 1 February 2012 at 6:14 pm

    The following Python program runs in 32ms.

    # rearranged (and in base 11):
    #
    #  DALEY
    # + GOLD
    # ------
    # THOMAS
    #
    # so: all letters are in the range [0, 10]
    # A+G > 10 and D+1 > 10, H = (D+1) % 11 and T = 1
    
    from itertools import permutations
    from enigma import printf
    
    def base11(*l):
      return ''.join('A' if x == 10 else str(x) for x in l)
    
    (T, D, H) = (1, 10, 0)
    
    d1 = set(range(11)).difference((T, D, H))
    
    # units: Y + D = S (mod 11)
    for Y in d1:
      (c1, S) = divmod(Y + D, 11)
      d2 = d1.difference((Y, S))
      if len(d2) != 6: continue
    
      # 11's: E + L + carry = A (mod 11)
      for (E, L) in permutations(d2, 2):
        (c2, A) = divmod(E + L + c1, 11)
        d3 = d2.difference((E, L, A))
        if len(d3) != 3: continue
    
        # 11^2's: L + O + carry = M (mod 11)
        for O in d3:
          (c3, M) = divmod(L + O + c2, 11)
          d4 = d3.difference((O, M))
          if len(d4) != 1: continue
          G = d4.pop()
    
          # 11^3's: A + G + carry = O (mod 11)
          (c4, o) = divmod(A + G + c3, 11)
          if not(c4 == 1 and o == O): continue
    
          THOMAS = base11(T, H, O, M, A, S)
          DALEY  = base11(D, A, L, E, Y)
          GOLD   = base11(G, O, L, D)
    
          printf("THOMAS={THOMAS} DALEY={DALEY} GOLD={GOLD} [base11]")
    
          assert int(THOMAS, 11) - int(DALEY, 11) == int(GOLD, 11)
    

    Solution: THOMAS = 103274 (base 11).

  2. Jim Randell 8 January 2013 at 2:40 pm

    Using the substituted sum solver from the enigma.py module, the following Python program can be used to solve this Enigma in 275ms (a shorter program, but slower).

    from enigma import SubstitutedSum
    
    p = SubstitutedSum(['DALEY', 'GOLD'], 'THOMAS', base=11)
    for r in p.solve():
      p.solution(r)
    

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: