Twelve Men on an Island Logic Puzzle

· Puzzles, Logic

One of my favorite shows right now is Brooklyn Nine-Nine. During season 2 episode 18, titled “Captain Peralta”, Captain Holt presents this riddle to the team:

There are twelve men on an island. Eleven weigh exactly the same amount, but one of them is slightly lighter or heavier. You must figure out which. The island has no scales, but there is a seesaw. You can only use it three times.

This isn’t exactly a programming post, but it does demonstrate the same kind of problem solving that is often found in devising efficient algorithms.

I decided to represent each islander with a letter from A to L. This makes it easy to unambiguously and concisely represent combinations of islanders. I show each trial with the seesaw as a column. The “Test” column shows what islanders are put on the seesaw as left vs. right. The “Result” column shows “=” if both sides were equal, “<” if the left side weighed less than the right, or “>” if the left side weighed more than the right. Then the “Possibilities” column shows what possible solutions remain given the result of the trial. As we move from the 1st trial towards the 3rd we can see the remaining possibilities reduce as more results eliminate solutions.

When solving this puzzle we know right away that we cannot rely on the seesaw always tilting to the left or right. This seems to be people’s initial attempt at solving this problem. Just put six on one side and six on the other and work your way down. However, 3 trials and only 2 possible results would only give us up to 8 solutions because 2 x 2 x 2 = 8. So we know that we have to rely some trials being balanced to find all the solutions. Therefore, it is probably not a good idea to put six vs. six because there is no way that seesaw could be balanced since the different islander would always be on the seesaw giving only two possible results which doesn’t tell us which side the different islander is on.

The first trial that gives the most information is to do four vs. four (ABCD vs. EFGH). No matter what the result we have reduced the possible solutions from 24 to 8.

PossibilitiesTestResultPossibilities
A lighter
A heavier
B lighter
B heavier
C lighter
C heavier
D lighter
D heavier
E lighter
E heavier
F lighter
F heavier
G lighter
G heavier
H lighter
H heavier
I lighter
I heavier
J lighter
J heavier
K lighter
K heavier
L lighter
L heavier
ABCD vs. EFGH=I lighter
I heavier
J lighter
J heavier
K lighter
K heavier
L lighter
L heavier
<A lighter
B lighter
C lighter
D lighter
E heavier
F heavier
G heavier
H heavier
>A heavier
B heavier
C heavier
D heavier
E lighter
F lighter
G lighter
H lighter

What we do for the second trial depends on the type of result for the first trial because the pattern of remaining possibilities is different.

Here is the full solution:

1st Trial2nd Trial3rd Trial
TestResultPossibilitiesTestResultPossibilitiesTestResultPossibilities
ABCD vs. EFGH=I lighter
I heavier
J lighter
J heavier
K lighter
K heavier
L lighter
L heavier
IJK vs. ABC=L lighter
L heavier
L vs. A=Impossible
<L lighter
>L heavier
<I lighter
J lighter
K lighter
I vs. J=K lighter
<I lighter
>J lighter
>I heavier
J heavier
K heavier
I vs. J=K heavier
<J heavier
>I heavier
<A lighter
B lighter
C lighter
D lighter
E heavier
F heavier
G heavier
H heavier
ABE vs. CDF=G heavier
H heavier
G vs. H=Impossible
<H heavier
>G heavier
<A lighter
B lighter
F heavier
A vs. B=F heavier
<A lighter
>B lighter
>C lighter
D lighter
E heavier
C vs. D=E heavier
<C lighter
>D lighter
>A heavier
B heavier
C heavier
D heavier
E lighter
F lighter
G lighter
H lighter
ABE vs. CDF=G lighter
H lighter
G vs. H=Impossible
<G lighter
>H lighter
<C heavier
D heavier
E lighter
C vs. D=E lighter
<D heavier
>C heavier
>A heavier
B heavier
F lighter
A vs. B=F lighter
<B heavier
>A heavier