# Enigmatic Code

Programming Enigma Puzzles

## Enigma 457: Divided by ex…

From New Scientist #1608, 14th April 1988 [link]

In the following division sum, letters are substituted for digits. The same letter stands for the same digit wherever it appears, and different letters stand for different digits.

Rewrite the sum with letters replaced by digits.

#### News

This puzzle brings the total number of Enigma puzzles on the site to 1192, which means there are now more than 2/3 of all Enigma puzzles published in New Scientist on the site. There is a full archive of puzzles from October 1999 to the final Enigma puzzle in December 2013 (728 puzzles), and also a full archive from the first Enigma puzzle in February 1979 up to this puzzle from April 1988 (462 puzzles — there were sometimes multiple puzzles at Christmas). This leaves around 600 puzzles to be posted. Thanks to the ongoing efforts of Hugh Casement I have been able to acquire the text for most of these remaining puzzles (I have 134 left to source), so I can continue to keep posting them. There are also 48 puzzles on the site from the Puzzle sequence (with 43 left to go), and 51 puzzles from the Tantalizer sequence (I think I will be able to source around 268 more of these). Happy Puzzling!

[enigma457]

### 2 responses to “Enigma 457: Divided by ex…”

1. Jim Randell 20 July 2018 at 8:52 am

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

This run file executes in 130ms.

Run: [ @repl.it ]

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

SubstitutedDivision

"hhmm / ex = dpx"

"hh - ex = ma"
"mam - mmm = pk"
"pkm - mhb = b"
```

Solution: The sum is: 9922 ÷ 74 = 134 (remainder 6).

2. geoffrounce 2 September 2018 at 6:07 pm
```import time
start = time.time()

from itertools import permutations

d = 1    # since d * ex = ex

for Q in permutations('1234567890', 5):
h, e, x, m, a = Q

if e == '0' or m == '0' : continue
hh = int(h + h)
ex = int(e + x)
ma = int(m + a)

if hh - ex == ma:
mam = int(m + a + m)
mmm = int(m + m + m)

Q1 = set('1234567890'). difference(Q)
for R in permutations(Q1, 3):
p, b, k = R
if p == '0' or b == '0': continue

pk = int(p + k)

if mam - mmm == pk:
pkm = int(p + k + m)
mhb = int(m + h + b)

if pkm - mhb == int(b):
dpx = int(str(d) + p + x)
hhmm = int(h + h + m + m)

if ex * dpx == hhmm - int(b):
print('Sum is {} / {} = {}, remainder {}'. \
format (hhmm, ex, dpx, b))
print(time.time() - start)   # 0.063 sec

# Sum is 9922 / 74 = 134, remainder 6

```

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