Thursday, December 15, 2011

Classic HAT Puzzle & Variants

There are four man standing in front of a firing-squad. Two of them (nr.1 & 3) wear a black hat and two of them (nr.2 & 4) wear a white hat. They are all facing the same direction and between nr.3 and nr.4 stands a brick wall (see picture). So nr.1 can see nr.2 & 3, nr.2 sees nr.3, nr.3 sees only the wall and nr.4 doesn't see a thing. The men know that there are two white and two black hats.
The commander of the firing-squad is willing to let the men go if one of them can say what color hat he is wearing. The men are not allowed to talk. The only thing they may say is "I'm wearing a white/black hat". If one of the men knows which hat he is wearing he must tell it and all men will be free.
Which man knows 100% sure what color hat he's wearing?

Variant---------------------------------------

In a variant of this puzzle there are 3 hats of one colour and only 1 hat of another, and the 3 prisoners can see each other i.e. A sees B & C, B sees A & C and C sees A & B. (D again not to be seen and only there to wear the last hat

Colored Hats Against the wall----------------------
100 men are in a room, each wearing either a white or black hat. Nobody knows the color of his own hat, although everyone can see everyone else's hat. The men are not allowed to communicate with each other at all (and thus nobody will ever be able to figure out the color of his own hat).
The men need to line up against the wall such that all the men with black hats are next to each other, and all the men with white hats are next to each other. How can they do this without communicating? You can assume they came up with a shared strategy before coming into the room

 THE DEVIL & COLORED HATS.-----------------------------------

100 people find themselves at the gates of hell. The devil tells them that they'll have a chance to go to heaven instead, but first they'll have to play a game.
The devil is going to line them all up in a straight queue, each person facing the back of the next person in line. The order of people in this line will be randomly chosen when the game starts.
He is then going to put a red or blue hat on each person. Each hat can be red or blue at random. Nobody knows the color their hat will be before the game starts.
Each person will be able to see the hat of everyone in front of them, but won't be able to see the hats of anyone behind them. Everyone can hear everyone else.
The devil will then then ask each person the color of their hat, starting at the back of the line and moving forward. Each person must just say "red" or "blue", without any extra intonation. People cannot communicate at all beyond merely saying the word "red" or "blue". If a person correctly says the color of their own hat, then they will be sent to heaven;; if they get the color wrong they stay in hell.
Before the game starts, the people are allowed to come up with a strategy to save as many people as possible. One man proposes that every other person says the color of the hat of the person in front of them, and then the people in between repeat that color to save themselves. "That will save a guaranteed 50 people, and will probably save around 75," he says.
"No," a woman says. "I've got a plan that is guaranteed to save 99 of us, maybe all of us."
What is the woman's plan?

Strategy:
The last prisoner will say black if there are odd number of black hats in front of him. For simplicity, lets assume they are in odd number.
  • Second last prisoner can count the black hats in front of him. If he gets odd number, he can conclude the hat on his head is white and black otherwise.
  • Third last prisoner, will keep his ear open on the previous answer and then he’ll calculate of total black hats in front of him and behind him. That way he can decide if total is a odd number and can predict his hat’s color.
  • Using this technique, n-1 prisoners can be guaranteed to be saved.

No comments:

Post a Comment