# Enigmatic Code

Programming Enigma Puzzles

## Enigma 89: A blank expression

From New Scientist #1232, 18th December 1980 [link]

In the following long division the divisor has disappeared completely and all but a few of the digits have also been removed, with the rest substituted by letters.

Write out the complete sum.

This completes the archive of puzzles from 1980.

[enigma89]

### 2 responses to “Enigma 89: A blank expression”

1. Jim Randell 13 May 2013 at 7:01 am

This Python program runs in 63ms.

```from enigma import irange, printf

# A / B = C
#
#        y C C C 0 C
#    ---------------
#  B ) A A p A x p A
#      D y
#      ---
#        E p
#        F x
#        ---
#          G G
#          H H
#          ---
#          I I x
#          J y J
#          -----
#              K p K
#              K p K
#              =====

# choose a value for y (non-zero)
for y in irange(1, 9):
# the divisor B is at most 2-digits as B * y = Dy
for B in irange(1, 99 // y):
Dy = B * y
(D0, r) = divmod(Dy, 10)
if not(D0 > 0 and r == y): continue
# A01 is Dy plus a single digit E0
for E0 in irange(1, 9):
A01 = Dy + E0
# A01 is two digits
if A01 > 99: continue
# choose a value for p
for p in irange(0, 9):
# C1 is Ep / B with remainder G0
Ep = 10 * E0 + p
(C1, G0) = divmod(Ep, B)
# C1 and G0 are single digits
if not(0 < C1 < 10 and 0 < G0 < 10): continue
# Fx is B * C1
(F0, x) = divmod(B * C1, 10)
# choose A3
for A3 in irange(0, 9):
G = G0 * 10 + A3
# C2 is G / B with remainder I01
(C2, I01) = divmod(G, B)
# C2 is single digit, I01 is two digit
if not(0 < C2 < 10 and 9 < I01 < 100): continue
# C3 is I / B remainder K0
(C3, K0) = divmod(I01 * 10 + x, B)
# C3 and K0 are single digits
if not(0 < C3 < 10 and 0 < K0 < 10): continue
# J has middle digit y
if ((C3 * B) // 10) % 10 != y: continue
# C45 is K / B with no remainder
for A6 in irange(0, 9):
(C45, r) = divmod(K0 * 100 + p * 10 + A6, B)
if r > 0: continue
# C45 has a leading zero
if not(0 < C45 < 10): continue
# and K has a middle digit of p
if ((B * C45) // 10) % 10 != p: continue

printf("{A01}{p}{A3}{x}{p}{A6} / {B} = {y}{C1}{C2}{C3}0{C45} [{Dy} {Ep} {F0}{x} {G} {H} {I01}{x} {J} {K}]", H=B*C2, J=B*C3, K=B*C45)
```

Solution: The sum is 8906402 ÷ 17 = 523906.

• Jim Randell 13 July 2014 at 10:42 am

Here’s a solution using the SubstitutedDivision() solver from the enigma.py library. It runs in 310ms.

```from enigma import SubstitutedDivision

SubstitutedDivision(
'????x??', '??', 'y?????',
[('??', '?y', '?'), ('?p', '?x', '?'), ('??', '??', '??'), ('???', '?y?', '?'), None, ('???', '?p?', '')]
).go()
```

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