# Enigmatic Code

Programming Enigma Puzzles

## Tantalizer 425: Beauty contest

From New Scientist #976, 20th November 1975 [link]

To enliven the tedium of the beauty contest, the judges started by each sealing his guess for the first four places, before even seeing the girls. Afterwards they opened the envelopes and scored one point for each girl mentioned who finished in the final four and a further nine points for each girl given her correct placing.

Winner, was trendy Bishop Bonhomie with 21 points for 1st. Miss Paignton, 2nd. Miss Lincoln, 3rd. Miss Oban, 4th. Miss Wigan. Next came Peter Pint the telepoet with 12 points for 1st. Miss Oban, 2nd. Miss Northampton, 3rd. Miss Formby, 4th. Miss Paignton. A mere 3 points were garnered by Chico the Chiropractor with 1st. Miss Wigan, 2nd. Miss Oban, 3rd. Miss Lincoln, 4th. Miss Formby. The booby prize went to Dan Dare the famous celebrity, who netted 2 points for 1st. Miss Northampton, 2nd. Miss Paignton, 3rd. Miss Wigan, 4th. Miss Oban.

Can you put the four winning girls in the right order?

[tantalizer425]

### One response to “Tantalizer 425: Beauty contest”

1. Jim Randell 10 July 2019 at 9:21 am

This Python program considers all possible sequences of 4 girls, and looks for one which satisfies all the judges scores.

It runs in 91ms.

Run: [ @repl.it ]

```from enigma import subsets, join, printf

# the four scores
scores = { 'PLOW': 21, 'ONFP': 12, 'WOLF': 3, 'NPWO': 2 }

def score(s, k):
return 9 * sum(a == b for (a, b) in zip(s, k)) + len(set(s).intersection(k))

# choose 4 girls
for s in subsets('FLNOPW', size=4, select='P'):
# check the scores
if all(score(s, k) == v for (k, v) in scores.items()):
printf("{s}", s=join(s, sep=", "))
```

Solution: 1st = Miss Formby; 2nd = Miss Lincoln; 3rd = Miss Oban; 4th = Miss Paignton.

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