# Enigmatic Code

Programming Enigma Puzzles

From New Scientist #997, 22nd April 1976 [link]

Mrs Green and Mrs Brown were conversing about their young in honeyed tones. The topic was prowess at simple arithmetic. Under a mantle of mutually admiring words, they had soon agreed to a duel. The offspring were summoned from the sand pit and set the task of adding seven, three and two.

Little Willie Green wrote done 7 + 3 + 2 = 12 in barely the time it takes to boil an egg. Tommy Brown was still chewing his pencil. Several minutes elapsed before he arrived at SEVEN + THREE + TWO = TWELVE. But Mrs Green’s consoling noises were short lived. Young Tommy, it emerged, had treated the problem as one in cryptarithmetic, with each different letter standing for a different digit.

What was his (correct) numerical rendering of TWELVE?

[tantalizer446]

### 2 responses to “Tantalizer 446: Unready reckoners”

1. Jim Randell 5 September 2018 at 9:56 am

This is a simple alphametic sum puzzle, which we can solve using the [[ SubstitutedSum() ]] solver from the enigma.py library.

This run file executes in 183ms.

Run: [ @repl.it ]

```#!/usr/bin/env python -m enigma -r

SubstitutedSum "SEVEN + THREE + TWO = TWELVE"
```

Solution: TWELVE = 102352.

We can make two different sums, because the values of N and O can be interchanged.

82524 + 19722 + 106 = 102352
82526 + 19722 + 104 = 102352

2. geoffrounce 6 September 2018 at 7:56 am
```from itertools import permutations

# 1st stage permutation
for P1 in permutations ('1234567890',3):
t, h, r  = P1
if t == '0': continue

# 2nd stage permutation
Q1 = set('1234567890'). difference(P1)
for P2 in permutations(Q1,3):
e, s, v = P2
if s == '0': continue
three = int(t + h + r + e + e)

# 3rd stage permutation
Q2 = Q1.difference(P2)
for P3 in permutations(Q2):
n, w, o, l = P3
if s == '0': continue
seven = int(s + e + v + e + n)
two = int(t + w + o)
twelve = int(t + w + e + l + v + e)

if seven + three + two == twelve:
print('{} + {} + {} = {}'.format(seven, three, two, twelve))

# 82526 + 19722 + 104 = 102352
# 82524 + 19722 + 106 = 102352
```

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