# Enigmatic Code

Programming Enigma Puzzles

## Puzzle 18: Division (letters for digits)

From New Scientist #1069, 15th September 1977 [link]

In this division sum each letter stands for a different digit. Rewrite the sum with the letters replaced by digits. [puzzle18]

### 2 responses to “Puzzle 18: Division (letters for digits)”

1. Jim Randell 17 July 2019 at 8:19 am

This puzzle can be handled directly by the [[ `SubstitutedDivision()` ]] solver from the enigma.py library.

The following run file executes in 140ms.

Run: [ @repl.it ]

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

SubstitutedDivision

"jbqxj / lx = alxj"

"jb - sj = x"
"xq - dl = hs"
"hsx - hdx = ly"
"lyj - lyj = 0"
```

Solution: The correct sum is: 84968 ÷ 26 = 3268. 2. GeoffR 17 July 2019 at 12:20 pm
```from itertools import permutations

for p in permutations('1234567890'):

a, l, x, j, b, q, s, d, h, y = p
if a == '0' or l == '0' or j =='0': continue
if s == '0' or x == '0' or d == '0' or h == '0': continue

lx, alxj = int(l + x), int(a + l + x + j)
jbqxj = int(j + b + q + x + j)

if lx * alxj != jbqxj: continue
sj, jb, sj = int(s + j), int(j + b), int(s + j)
if int(a) * lx == sj and jb - sj == int(x):
ls, dl = int(l + s), int(d + l)
xq, hs = int(x + q), int(h + s)

if int(l) * lx == dl and xq - dl == hs:
hdx, hsx = int(h + d + x), int(h + s + x)
ly, lyj = int(l + y), int(l + y + j)

if int(x) * lx == hdx and hsx - hdx == ly \
and int(j) * lx == lyj:
print(f"Sum is {lx} * {alxj} = {jbqxj} ")
print(f"a={a},l={l},x={x},j={j},b={b},q={q},s={s},d={d},h={h},y={y}")

# Sum is 26 * 3268 = 84968
# a=3,l=2,x=6,j=8,b=4,q=9,s=7,d=5,h=1,y=0
```

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