Enigmatic Code

Programming Enigma Puzzles

Enigma 29: One letter wrong

From New Scientist #1171, 6th September 1979 [link]

In this addition sum, with letters substituted for digits, there is, I’m afraid, a mistake. The first two lines across are correct, but in the third line across there has been a mistake and one of the letters is incorrect. Apart from this unfortunate error (due of course to Uncle Bungle) each letter stands for the same digit wherever it appears and different letters stand for different digits.

Enigma 29

Find the mistake and write out the correct addition sum.

Note: When it’s talking about “first two lines across” it is referring to the summands, and the “third line across” refers to the result of the sum.


One response to “Enigma 29: One letter wrong

  1. Jim Randell 31 December 2012 at 9:15 am

    The following Python program runs in 731ms.

    from itertools import permutations
    from enigma import irange, nconcat, split, printf
    ds = irange(0, 9)
    for s in permutations(ds, 6):
      (H, B, D, M, P, A) = s
      if H == 0: continue
      a = nconcat(H, B, B, D, B, M, D, B)
      b = nconcat(H, B, B, B, P, A, D, B)
      c = a + b
      d = list(split(c, int))
      # the result should have 9 digits
      if len(d) != 9: continue
      # which digit of the result is wrong?
      f = (d[0] != M,
           d[1] != B,
           d[2] != H,
           d[3] in s,
           d[4] in s + (d[3],),
           d[5] in s + (d[3], d[4]),
           d[6] in s + (d[3], d[4], d[5]),
           d[7] != B,
           d[8] != H)
      # only one of these should be true
      if len(list(x for x in f if x)) != 1: continue
      n = f.index(True) + 1
      printf("{a} + {b} = {c}, digit {n} of original result is incorrect")

    Solution: The second digit, B, of the result should have been P. So, the result of the sum should have been written MPHEGTXBH. The correct sum is 84474174 + 84446374 = 168920548.

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: