# Enigmatic Code

Programming Enigma Puzzles

## Enigma 205: Doing it by halves

From New Scientist #1351, 31st March 1983 [link]

I was half-expecting something out of the ordinary when Archie presented me with the cross-number puzzle below. So I was not altogether surprised to see that half of the clues were missing, nor to hear his half-baked explanation of how he had rescued the paper they were written on from the grate in his living room.

Across:

1. Seven times 3 down. Also starts or ends with the same two digits as 7 across.
7. Nine times (4 across minus 5 down).

Down:

2. Three times 6 across.
4. A multiple (not 1) of 2 down.

All I want to know is: what is the difference between 6 across and 7 across?

[enigma205]

### One response to “Enigma 205: Doing it by halves”

1. Jim Randell 11 July 2014 at 8:01 am

This Python program runs in 171ms.

```from enigma import irange, printf

# consider possible values for 3d (3-digits)
# but 1a = 7 x 3d and is 4 digits
for d3 in irange(143, 999):
# 1a (4-digits) = 7x 3d
a1 = 7 * d3
# the final digit of 1a is the first digit of 3d
if a1 % 10 != d3 // 100: continue

# 7a is a 4-digit multiple of 9 (= 9 x (4a - 5d))
for a4d5 in irange(112, 999):
a7 = 9 * a4d5

# 1a and 7a start or end with the same digits
if not(a1 % 100 == a7 % 100 or a1 // 100 == a7 // 100): continue

# 5d shares digits with 4a and 7a
d5c = (a7 // 10) % 10
for d5ab in irange(10, 99):
d5 = 10 * d5ab + d5c
a4 = a4d5 + d5
if a4 > 999: continue
if a4 % 10 != d5 // 100: continue

# 2d is 3 x 6a
for a6a in irange(1, 9):
a6 = a6a * 100 + ((d5 // 10) % 10) * 10 + d3 % 10
d2 = ((a1 // 100) % 10) * 100 + ((a4 // 10) % 10) * 10 + a6a
if d2 != 3 * a6: continue

# 4d is a multiple of 2d
for d4b in irange(1, 9):
d4 = (a4 // 100) * 100 + d4b * 10 + a7 // 1000
(d, r) = divmod(d4, d2)
if r > 0 or d == 1: continue