Enigmatic Code

Programming Enigma Puzzles

Puzzle 53: Addition

From New Scientist #1104, 25th May 1978 [link]

In the following addition sum the digits have been replaced by letters. The same letter stands for the same digit wherever it appears and different letters stand for different digits.

Find the digits for which the letters stand.

[puzzle53]

2 responses to “Puzzle 53: Addition

  1. Jim Randell 28 February 2018 at 8:53 am

    We can use the [[ SubstitutedSum() ]] solver from the enigma.py library to solve this puzzle without needing to write a program.

    Run: [ @repl.it ]

    % python -m enigma SubstitutedSum "DHGDNGNC + CHCDNDGD = EPBNBBGE"
    (DHGDNGNC + CHCDNDGD = EPBNBBGE)
    (53650604 + 43450565 = 97101169) / B=1 C=4 D=5 E=9 G=6 H=3 N=0 P=7
    

    Solution: The actual sum is:

  2. geoffrounce 28 February 2018 at 7:14 pm

    Faster than expected (108 msec on my laptop) to find the solution with a permutation solution .

    import time
    start = time.time()
    
    from itertools import permutations
    
    for q in permutations('1234567890',8):
        b, c, d, e, g, h, n, p = q
        if d == '0' or c == '0' or e == '0': continue
        DHGDNGNC  = int(d + h + g + d + n + g + n + c)
        CHCDNDGD  = int(c + h + c + d + n + d + g + d)
        EPBNBBGE =  int(e + p + b + n + b + b + g + e)
        if DHGDNGNC + CHCDNDGD == EPBNBBGE:
            print(DHGDNGNC, " + ", CHCDNDGD, " = ", EPBNBBGE)
            print(time.time() - start)   # 0.108 sec
    

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: