# Enigmatic Code

Programming Enigma Puzzles

## Enigma 223: Addition. Digits all wrong

From New Scientist #1369, 4th August 1983 [link]

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

Find the correct addition sum.

There are now 712 puzzles on the site, which is exactly 40% of the total number of Enigma puzzles (1780). Although because some Enigmas share numbers (particularly at Christmas) this probably slightly underestimates that total number of Enigmas that I have yet to publish.

Note: I am waiting for a phone line to be connected at my new house, so I only have sporadic access to the internet at the moment. The current estimate is that the line will be connected at the end of September 2014.

[enigma223]

### 2 responses to “Enigma 223: Addition. Digits all wrong”

1. Jim Randell 18 September 2014 at 3:49 pm

This puzzle is similar to Enigma 35 and Enigma 171.

The SubstitutedSum() solver from the enigma.py library makes short work of this kind of puzzle.

The following Python program runs in 121ms.

```from enigma import SubstitutedSum

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

p = SubstitutedSum(['24534', '19542', '44711'], '91086', d2i=d2i)
for s in p.solve():
print(p.substitute(s, p.text))
```

Solution: The correct sum is: 12902 + 48921 + 22544 = 84367.

2. geoffrounce 18 September 2014 at 6:08 pm
```# a b c d e f g h i j
# 1 2 3 4 5 6 7 8 9 0

# bdecd  24534
# aiedb  19542
# ddgaa  44711
# -----  -----
# iajhf  91086
#------  -----

from itertools import permutations

for p in permutations('1234567890'):
a,b,c,d,e,f,g,h,i,j = p
if 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':
if all (x != '0' for x in(b,a,d,i)):
bdecd = int(b+d+e+c+d)
aiedb = int(a+i+e+d+b)
ddgaa = int(d+d+g+a+a)
iajhf = int(i+a+j+h+f)
if bdecd + aiedb + ddgaa == iajhf:
print(bdecd,'+',aiedb,'+',ddgaa,'=',iajhf)

# Ans: 12902 + 48921 + 22544 = 84367
```