There are 100 prisoners in a jail. Since the jail will be closed, the prisoners are either released or executed. They are lined up in a single line in the backyard, and the guardians put a hat every prisoner's head, colored either black or white. The line is formed in a way that each prisoner can see the color of the hat of every prisoner in front of him, but none behind him, and no one can see their own hats. This way the first in line doesn't see any, the second sees the first, the third the first two, etc.
Now, starting with the last one in the line, every prisoner has to shout a color, black or white. If what he says matches his hat's color, he is released, otherwise he's shot in the head. All the other prisoners will hear what he shouted, and they will also hear weather he was shot or not. There's no communication between the prisoners, they have no knowledge of how many black/white hats there are in total, but they can agree on a strategy before the whole process starts.
What is the best strategy to save the most number of prisoners? How many prisoners can be saved for sure?
The last person in the line has no information. So he can only hope that he is correct with a 50% chance. So he decides to help out his fellow prisoners. He says white if the number of caps white caps he sees on the heads of the other 99 prisoners is even, and black if it is odd.
Now the 99th person, knows whether to total number of caps is even, and he can see the other 98 caps. So he can deduce the color of had on his head, and would be let off.
The 98th person knows whether the total number of caps is even. He also knows the color of the cap on the 99th person's head. So he can compute the color of the cap on his head.
This way each person is able to correctly answer except the last person in line. There is a 50% chance that the last person will also be released.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment