Problem about prisoners and caps, the color of which needs to be determined
Recreation / / December 31, 2020
The closing system sees all the caps, but can only say "black" or "white", while simultaneously informing everyone of the hidden information. The prisoners do not know the total number of black and white caps, there are more than two possible options. But they are limited to only two versions when it comes to the concept of parity: the number can be either even or odd.
The key to solving the problem is this: the prisoners agree that the first responder will say, for example, "black", if he sees an odd number of black caps in front, and "white" if he sees an even number of black caps.
Let's look at the example from the picture above. The tallest prisoner # 1 sees three black caps ahead. He says "black" out loud. This gives everyone else the information that there is an odd number of black caps ahead. The first prisoner made a mistake with the color of his cap, but this is not scary: once it is allowed to answer incorrectly.
Prisoner # 2 sees an odd number of black caps in front of her. She realizes that she is white and answers correctly. Prisoner # 3 sees an even number of black caps and guesses that he is wearing a black cap that the first two captives saw.
Captive No. 4 hears the answer and realizes that she should look for an even number of black caps, because there was a black one behind her back, but she sees only one ahead and concludes that her cap is black. Prisoners No. 5-9 are looking for an odd number of black caps, which they just see, while realizing that they are wearing white caps. The turn comes to the tenth prisoner. If prisoner # 9 saw an odd number of black caps, this means only one thing - prisoner # 10 has a black cap.
This is how this algorithm will work for any set of hubcaps. For the first participant, the probability of an incorrect answer is 50%, but the information about even-odd parity, which he will give, will allow the rest of the captives to guess the color of their cap.
Each respondent will begin to estimate the number of even and odd caps ahead. If the number calculated in his mind does not coincide with what he sees, then his cap is the same color. Each time in this case, the next responder takes into account that the even-oddness of the remaining caps has now changed.
This puzzle is a translation of a TED-Ed video.