# Enigmatic Code

Programming Enigma Puzzles

## Enigma 516: The ABC of division

From New Scientist #1668, 10th June 1989 [link]

In the following division sum each letter stands for a different digit. Rewrite the sum with the letters replaced by digits.

[enigma516]

### 2 responses to “Enigma 516: The ABC of division”

1. Jim Randell 9 September 2019 at 8:12 am

We can use the [[ `SubstitutedDivision()` ]] solver from the enigma.py library to solve this puzzle.

The following run file executes in 102ms.

Run: [ @repl.it ]

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

SubstitutedDivision

"qsmcaq / csm = ween"

"qsm - csm = wbb"
"wbbc - nhn = wea"
"weaa - nhn = snn"
"snnq - sqwe = shs"
```

Solution: The correct sum is: 539465 ÷ 439 = 1228 (remainder 373).

2. GeoffR 19 September 2019 at 11:22 am
```# this enigma puzzle uses 10 different letters for digits 0..9

from itertools import permutations
for p in permutations ('1234567890'):
c, s, m, w, e, n, q, a, b, h = p

if '0' in {q, w, c, s, n}: continue

# find variables in overall sum, including remainder
csm = int(c + s + m)
ween = int(w + e + e + n)
qsmcaq = int(q + s + m + c + a + q)
shs = int(s + h + s) # remainder

if int(e) * csm == int(n + h + n):
if csm * ween + shs == qsmcaq :
print(f"Sum is {csm} * {ween} = {qsmcaq}, remainder {shs}")

# Sum is 439 * 1228 = 539465, remainder 373
```

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