Three prisoners are standing in a circle. They are blindfolded and either a red or blue hat is placed randomly on the head of each prisoner. When the blindfold is removed they can see the colour of the hats on the other two prisoners but not their own. They cannot communicate in any way.
They are each given a piece of paper on which they must write “red”, “blue” or “abstain”. They are allowed to go free if at least one prisoners guesses their hat colour correctly, and none guess incorrectly.
The prisoners find out about this the day before and attempt to find a strategy over night. What is the strategy which maximises their probability of going free?
All three prisoners follow the same rule:
- If the other two prisoners have matching hat, guess the opposite colour.
- If the other two prisoners have different colour hats, abstain.
This results in a 75% chance of victory.
Proof
If all 3 hats are the same, all 3 prisoners will guess wrong. This happens with
probability
For every possible arrangement where a prisoner
Extension
This problem can be generalised to the case where there are
We can represent the prisoners as bits, with (red, blue) being equivalent to (0,
1). For a problem of size
Our strategy for each prisoner is to check if they looks like they are in a “good” arrangement. If they are, then they write down the opposite of what the arrangement says. Otherwise, they abstain.
We can see that in a “good” arrangement, everyone guesses wrong. This happens
in
However, in all other arrangements, exactly one person writes down their hat
colour (correctly), and all the others abstain. This is because the Hamming
code corrects for one bit errors. This happens in
This is optimal since when we are wrong, all prisoners are wrong together. However, when we are right, only one prisoner votes.
The probability that we are right,
We can see that as the number of prisoners grows we get higher chances of winning.