Enigmatic Code

Programming Enigma Puzzles

Enigma 1666: Siblings to infinity

From New Scientist #2832, 1st October 2011 [link]

ROY and MARY are twins. They agree that life is just DANDY, according to the equation shown.

They even like MONDAY, which represents which six digits?

[enigma1666]

One response to “Enigma 1666: Siblings to infinity”

1. Jim Randell 3 December 2011 at 11:15 pm

The following Python code runs in 60ms.

```# ROY / MARY = 0.DANDY...
# hence: 99999 x ROY = MARY x DANDY
# note: the final digit of the product is Y x Y and 9 x Y, so: Y is 0, 4, 5, 9

from enigma import irange, concat, printf

for R in irange(1, 9):
for O in irange(0, 9):
for Y in (0, 4, 5, 9):
ROY = int(concat(R, O, Y))
x = 99999 * ROY
for M in irange(1, 9):
for A in irange(0, 9):
MARY = int(concat(M, A, R, Y))
(d, r) = divmod(x, MARY)
if r > 0: continue
DANDY = '{d:05d}'.format(d=d)
if DANDY[0] != DANDY[3]: continue
if int(DANDY[1]) != A: continue
if int(DANDY[4]) != Y: continue
MONDAY = concat(M, O, DANDY[2:4], A, Y)
printf("MONDAY={MONDAY} [{ROY}/{MARY}={f}]", f=float(ROY)/float(MARY))
```

Solution: MONDAY = 257149.

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