Enigmatic Code

Programming Enigma Puzzles

Enigma 51: Uncle’s error again

From New Scientist #1194, 14th February 1980 [link]

In the addition sum below, letters have been substituted for digits. When Uncle Bungle made up this sum he intended that the same letter should stand for the same digit wherever it appeared, and that different letters should stand for different digits. And indeed that is generally the case. But unfortunately there was an exception. Uncle Bungle made a careless mistake and one letter was wrong.

Enigma 51

Which letter was wrong? Write out the sum with numbers substituted for letters.


One response to “Enigma 51: Uncle’s error again

  1. Jim Randell 28 January 2013 at 8:23 am

    Using the substituted sum solver from the enigma.py library, the following Python program runs in 42ms.

    from enigma import SubstitutedSum, sprintf, printf
    # the leftmost columns are X + X + X + carry = XX
    # the maximum possible carry is 2, so 3X + c = 11X
    # hence: 8X = c, and c = 0, 1 or 2
    # the only possible integer value of X is 0,
    # but (presumably) leading zeros are not allowed.
    # hence one of these 5 X's is where the error is.
    # possible carries into the X's
    for c in (0, 1, 2):
      p = SubstitutedSum(['EBHLLNL', 'RBNGLNL', 'EPNWLNL'], 'cXGNNNHN', l2d={'c': c}, d2i={})
      for s in p.solve():
        X = s['X']
        # either the XX of the sum is wrong, and should be 3 * X + c
        xx = str(3 * X + c)
        # but one of the digits should be X
        if xx.count(str(X)) == 1:
          # so the actual sum is...
          r = sprintf('X{t[0]} + X{t[1]} + X{t[2]} = {xx}{r} [not XX{r}]', t=p.terms, r=p.result[1:])
          print(p.substitute(s, r))
        # or the XX is right and one of the X + X + X is wrong
        # but we don't know which one, so let's assume it's the first one
        # so XX = X + X + x + c, x = 9X - c
        x = 9 * X - c
        # and it has to be a single digit
        if 0 <= x < 10:
          # and the actual sum is...
          r = sprintf('{x}{t[0]} [not X{t[0]}] + X{t[1]} + X{t[2]} = XX{r}', t=p.terms, r=p.result[1:])
          print(p.substitute(s, r))

    Solution: The first X in the result is incorrect (it should have been W). The actual sum is: 50874424 + 53826424 + 50921424 = 155622272.

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: