Solution Of Prisoner Hat Riddle



Click here for link to Question

The key is that the person at the back of the line who can see everyone else's hats can use the words "black" or "white" to communicate some coded information. So what meaning can be assigned to those words that will allow everyone else to deduce their hat colors? It can't be the total number of black or white hats. There are more than two possible values, but what does have two possible values is that number's parity, that is whether it's odd or even. So the solution is to agree that whoever goes first will, for example, say "black" if he sees an odd number of black hats and "white" if he sees an even number of black hats.
Odd number of hats

Even Number of hats

Let's see how it would play out if the hats were distributed like this.

The tallest captive sees three black hats in front of him, so he says "black," telling everyone else he sees an odd number of black hats. He gets his own hat color wrong,but that's okay since you're collectively allowed to have one wrong answer.

Prisoner two also sees an odd number of black hats, so she knows hers is white, and answers correctly.

Prisoner three sees an even number of black hats, so he knows that his must be one of the black hats the first two prisoners saw.
Prisoner four hears that and knows that she should be looking for an even number of black hats since one was behind her. But she only sees one, so she deduces that her hat is also black.
Prisoners five through nine are each looking for an odd number of black hats, which they see, so they figure out that their hats are white.
Now it all comes down to you at the front of the line. If the ninth prisoner saw an odd number of black hats, that can only mean one thing.


You'll find that this strategy works for any possible arrangement of the hats. The first prisoner has a 50% chance of giving a wrong answer about his own hat, but the parity information he conveys allows everyone else to guess theirs with absolute certainty.

Each begins by expecting to see an odd or even number of hats of the specified color.
If what they count doesn't match,that means their own hat is that color. And everytime this happens, the next person in line will switch the parity they expect to see.
So that's it, you're free to go. It looks like these aliens will have to go hungry, or find some less logical organisms to abduct.

Thank you.

Click Science and Mathematics for more interesting and helpful posts.

Follow me on Quora and Twitter

No comments:

Post a Comment

Wormholes Explained – Breaking Spacetime

If you saw a wormhole in reality, it would appear round, spherical, a bit like a black hole. Light from the other side passes through and gi...