Enigmatic Code

Programming Enigma Puzzles

Enigma 254: Triangular addition

From New Scientist #1401, 15th March 1984 [link]

Below is an addition sum with letters substituted for digits. The same letter stands for the same digit whenever it appears, and different letters stand for different digits:

Enigma 254

Write the sum out with numbers substituted for digits.



3 responses to “Enigma 254: Triangular addition

  1. Jim Randell 29 January 2015 at 8:11 am

    This is exactly the type of puzzle that I wrote the SubstitutedSum() for the enigma.py library. It makes short work of this problem – the following Python code runs in 42ms.

    I’ve recently added the go() method to the SubstitutedSum() and SubstitutedDivision() solvers, so that problems like this can be solved with a single line of code.

    from enigma import SubstitutedSum
    SubstitutedSum(['G', 'CG', 'CQG', 'GHCG', 'THXQG'], 'HPBHT').go()

    Solution: The numerical sum is: 9 + 89 + 839 + 9689 + 56439 = 67065.

    • geoffrounce 29 January 2015 at 9:46 am
      from itertools import permutations
      for p in permutations('9876543210',8):
        c,q,g,h,t,x,p,b = p
        if all(z != '0' for z in(g,c,t,h)):
          G,CG,CQG = int(g),int(c+g), int(c+q+g)
          GHCG,THXQG = int(g+h+c+g), int(t+h+x+q+g)
          HPBHT = int(h+p+b+h+t)
          if G + CG + CQG + GHCG + THXQG == HPBHT:
  2. Hugh Casement 30 January 2015 at 11:17 am

    I do find it shows singular lack of imagination to use a random jumble of letters in these substitution puzzles.  I know it makes no difference to either the solution or the method, but wouldn’t it be more interesting with real words?  Not always possible to find valid words for all the numbers, of course, but they could at least try.  For example:


    Ars longa, vita brevis!

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: