# Enigmatic Code

Programming Enigma Puzzles

## Enigma 232: The judgement of Paris

From New Scientist #1378, 6th October 1983 [link]

One day, a handsome shepherd named Paris was minding his own business, when three goddesses hove on sight. They produced a golden apple and demanded that he award it to the fairest of them. The ancient legend then says that each offered him a thumping bribe on the quiet. But that is a libel and the true story is as follows.

Reflecting that beauty is only skin deep, he decided that there must be other criteria as well. He would rank the goddesses by each criterion, awarding x points for 1st place, y for 2nd, and z for 3rd (xy and z were descending positive whole numbers and no ties occurred). He then totalled the points and found that, helped no doubt by coming top for Beauty, although not for Conversation, Aphrodite had won. Hera totalled 20 points and Athena, despite being top for Wisdom, only 9.

The long term results are reported in the Iliad. The question for now is who scored precisely how many points in the Interesting Hobbies section of the contest?

The original problem said: “beauty is only sin deep”.

Note: I am still waiting for a phone line to be connected at my new house, so I only have sporadic access to the internet at the moment. I’ve no idea when I will get connected.

[enigma232]

### One response to “Enigma 232: The judgement of Paris”

1. Jim Randell 25 October 2014 at 1:57 pm

This Python 3 program runs in 275ms.

```# x > y > z > 0
#
# so the minimum values are x=3, y=2, z=1
#
# Athena scores 9 and is first in one round
# 9 = 3 + 1 + 1 + 1 + 1 + 1 + 1, so there are at most 7 rounds
#
# there are at least 4 rounds (Beauty, Conversation, Wisdom, Hobbies)

from itertools import combinations, permutations
from enigma import irange, printf

# generate possible assignments of points
# n - number of rounds
# x, y, z - points for 1st, 2nd, 3rd
# s - accumulated rounds
def generate(n, x, y, z, rs):
# are we done?
if n == 0:
yield rs
else:
# round number
r = len(rs)
# generate scores for the next round, (<Aph>, <Ath>, <Her>)
for s in permutations((x, y, z)):
# check rounds we are given
if r == 0 and s[0] != x: continue # round 0 = Beauty
if r == 1 and s[0] == x: continue # round 1 = Conversation
if r == 2 and s[1] != x: continue # round 2 = Wisdom
yield from generate(n - 1, x, y, z, rs + [s])

# consider the number of rounds
for n in irange(4, 7):
# choose x, y, z
# Athena scored 9, so x can be at most (9 - (n - 1)) = 10 - n
for (x, y, z) in combinations(irange(10 - n, 1, step=-1), 3):
# generate scores for each of the n rounds
for rs in generate(n, x, y, z, []):
# total scores
t = tuple(sum(x) for x in zip(*rs))
if not(t[0] > 20): continue # Aphrodite won (> 20)
if not(t[1] == 9): continue # Athena scored 9
if not(t[2] == 20): continue # Hera scored 20

# round 3 = Hobbies
printf("hobbies(Aph, Ath, Her)={rs[3]} [scores={t} rounds={rs}]")
```

Solution: In the Interesting Hobbies section Hera scored 5, Aphrodite scored 4, Athena scored 1.

There were 5 rounds: Beauty, Conversation, Wisdom, Interesting Hobbies and one other that is not mentioned in the text.

The points distributed are: 5 points for 1st place, 4 points for 2nd place, 1 point for 3rd place.

There’s only one possible distribution of points in the contest: