# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1635: Marty’s date

From New Scientist #2801, 26th February 2011 [link]

Our niece Ennie, nephew Iggy and their friend Marty were born on different dates in December. Ennie’s birth date is the 19th and Iggy’s is the 21st. The trio have tried writing down all numbers that can be expressed as a multiple of 19 plus a multiple of 21 plus a multiple of Marty’s birth date, where in each case the whole-number multiple can be zero or more.

They have managed to express 189 as a sum of multiples, and indeed any higher number can be similarly expressed. But it is impossible to express 188 in this way.

What is Marty’s birth date?

[enigma1635]

### One response to “Enigma 1635: Marty’s date”

1. jimrandell 12 December 2011 at 5:32 pm

The following Python program executes in 29ms.

```def check(q):
# weed out any q that divides 188 directly
if 188 % q == 0: return False
# otherwise see if we can find suitable m, n, p
for m in range(0, 9):
for n in range(0, 10):
x = 188 - (21 * m) - (19 * n)
if not(x > 0): continue
(p, r) = divmod(x, q)
if r > 0: continue
return False
return True

# q is the number we are looking for
for q in range(1, 32):
if q in (19, 21): continue
if check(q):
print(q)
```

Solution: Marty’s birthdate is 23rd December.

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