# Enigmatic Code

Programming Enigma Puzzles

## Enigma 103: Aftermath

From New Scientist #1247, 2nd April 1981 [link]

“Written the thank-you letters yet, dear?”

“Just going to. Do I thank Uncle Arthur for the umbrella, Aunt Barbara for the thriller, Cousin Cuthbert for the record? Aunt Daphne for the stilton and Uncle Edward for the port?”

“You wouldn’t score full marks for that!”

“Well how about Arthur for the thriller, Barbara for the record, Cuthbert for the stilton, Daphne for the umbrella and Edward for the port?”

“That’s better but far from right.”

“Then Arthur for the record, Barbara for the port, Cuthbert for the stilton, Daphne for the thriller and Edward for the umbrella?”

“Better again but still not right. Cuthbert did not give us the stilton. Nor the port, for that matter.”

“Oh, Gawd! Then who did give us what?”

[enigma103]

### 2 responses to “Enigma 103: Aftermath”

1. Jim Randell 30 June 2013 at 10:27 am

It’s easy enough to consider all possible permutations programatically. This Python program runs in 40ms.

```from itertools import permutations
from enigma import printf

(A, B, C, D, E) = names = list('ABCDE')
(P, R, S, T, U) = presents = list('PRSTU')

# how many are correct
def count(d, ps):
return sum(1 for (n, p) in zip(names, ps) if d[n] == p)

for ps in permutations(presents):
# assign presents to names
g = dict(zip(names, ps))
if g[C] in (S, P): continue
# guesses
if count(g, 'UTRSP') < count(g, 'TRSUP') < count(g, 'RPSTU') < 5:
print(' '.join(n + '=' + g[n] for n in names))
```

Solution: Arthur gave the record; Barbara gave the port; Cuthbert gave the thriller; Daphne gave the umbrella; Edward gave the stilton.

• Jim Olson 30 June 2013 at 6:35 pm

This is one of those pure logic enigmas that I think are very enjoyable to solve. There seem to be less of these types of enigmas now.

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