# Enigmatic Code

Programming Enigma Puzzles

## Enigma 276: Wrong figures to add

From New Scientist #1423, 27th September 1984 [link]

In the following addition sum all the digits are wrong. But the same wrong digit stands for the same correct digit wherever it appears, and the same correct digit is always represented by the same wrong digit.

[enigma276]

### 3 responses to “Enigma 276: Wrong figures to add”

1. Jim Randell 27 April 2015 at 8:11 am

This puzzle can be fed directly to the SubstitutedSum() solver in enigma.py. It doesn’t care if the symbols used in the sum are letters or digits.

This Python program runs in 132ms.

```from enigma import SubstitutedSum

# invalid assignments
d2i = {
# there are no leading zeros, and digits cannot stand for themselves
0: '0179',
1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9',
}

SubstitutedSum(['1964', '9538', '1664', '7068'], '11247', d2i=d2i).go()
```

Solution: The correct sum is: 2791 + 7643 + 2991 + 8593 = 22018.

• geoffrounce 27 April 2015 at 9:06 am
```# using a,b,c,d,e,f,g,h,i,j for the 10 digits, let:
# a != '1' and b !='2' and c !='3' and d !='4' and e !='5'
# and f !='6' and g !='7' and h !='8' and i !='9' and j !='0'
from itertools import permutations

for p in permutations('1234567890',4):
a, i, f, d = p
if a != '1' and i != '9' and f != '6' and d != '4':
n1 = int(a + i + f + d)                   # ie not 1964

# easier to permute 3rd number before 2nd number
n2 = int(a + f + f + d)                   # ie not 1664
p2 = set('1234567890').difference(p)

# find 3 more digits
for q in permutations(p2,3):
e, c, h = q
if e != '5' and c != '3' and h != '8':
n3 = int(i + e + c + h)               # ie not 9538
p3 = p2.difference(q)

# find last 3 digits and two more numbers
for r in permutations(p3,3):
g, j, b = r
if g != '7' and j != '0' and b != '2':
n4 = int(g + j + f + h)           # ie not 7068
n5 = int(a + a + b + d + g)       # ie not 11247
if n1 + n2 + n3 + n4 == n5:
print(n1,'+',n2,'+',n3,'+',n4, '=',n5)

# Ans: 2791 + 2991 + 7643 + 8593 = 22018
```
• Hugh Casement 28 April 2015 at 1:56 pm

I can think of a different letter substitution:
ably + ally + bump + help = aaryh !

This site uses Akismet to reduce spam. Learn how your comment data is processed.