Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!

# Only for those who don't know this riddle ...

Vinod John
Ranch Hand
Posts: 162
There were 3 white hats and 2 black hats. The Jailor make three prisoners to sit one behind the other in such a way the first prisoner can't see any of the prisoners hat , the second one can see only the hat worn by the first and the third can see the hat worn by other two prisoner.
Now the Jailor blindfolds all the prisoners and make them were a hat and threw away the other two hats out of sight, and promise to free the prisoner who can figure out the color of hat he was wearing.
After few minute the first prisoner answers the question correct and was freed. What was the color of the hat he was wearing ?.

Ashok Mash
Ranch Hand
Posts: 1936
White.
How he got it right? Pure luck!

Greg Harris
Ranch Hand
Posts: 1012
because black and white are shades (not colors), the prisoner simply said, "my hat has no color."

Greg Neef
Ranch Hand
Posts: 82
if the prisoner who can see two hats, sees two black ones his must be white.

Junilu Lacar
Bartender
Posts: 7306
45
I think there's more to the question than you gave. Doesn't the jailer take the blindfolds off after he puts the hats on the prisoners and don't the second and third prisoners both say "I don't know what color hat I'm wearing."? Then the first prisoner can deduce what color of hat he's wearing.

Junilu Lacar
Bartender
Posts: 7306
45
Originally posted by Greg Neef:
if the prisoner who can see two hats, sees two black ones his must be white.

You're on the right track here. You need to go down the line and carry it to it's logical conclusion.
You have to make the assumption that all three prisoners are smart and have thought out the situation fully and logically before they answer.

Junilu Lacar
Bartender
Posts: 7306
45
Originally posted by Ashok Krishnan:
How he got it right? Pure luck!

Nothing to do with luck. The first prisoner can answer with 100% certainty what color hat he is wearing.

Michael Dunn
Ranch Hand
Posts: 4632
(P-prisoner, W-white, B-black)
I'm assuming P3 answers 1st, P2 next, P1 last.
If P3 answers W - he must see 2xB
If P3 answer is unsure - he sees 1xW and 1xB, or 2xW
If P2 answers W - he must see 1 x B
If P2 answer is unsure - he must see W
(If the clue is no-one but P1 answers, therefore P3 and P2 are unsure, then P1's answer would be W)

Vinod John
Ranch Hand
Posts: 162
Originally posted by Junilu Lacar:
Doesn't the jailer take the blindfolds off after he puts the hats on the prisoners

You are right I did miss that.
Originally posted by Junilu Lacar:

and don't the second and third prisoners both say "I don't know what color hat I'm wearing."? Then the first prisoner can deduce what color of hat he's wearing

I thought that would give more clue to solve the problem and also I added "After few minutes" that is actually that make it bit obvious that they don't know the answer.

Vinod John
Ranch Hand
Posts: 162
Originally posted by Ashok Krishnan:
White.
How he got it right? Pure luck!

So are you
but Mike explaination was perfect.

Anupam Sinha
Ranch Hand
Posts: 1090
Vinod : "I thought that would give more clue to solve the problem and also I added "After few minutes" that is actually that make it bit obvious that they don't know the answer"
WoW, whats the logic behind the way you think that.
What you thought obvious was very required and what you forget made the puzzle a more of a guess work.
[ August 22, 2003: Message edited by: Anupam Sinha ]

Joel McNary
Bartender
Posts: 1840
Actaully, most of the versions that I've heard have the prisoners/job applicants/whatever not answering for several minutes. The fact that no one is sure about anything gives you enough information to be sure. The other two don't actaully need to say anything; the fact that they have not said anything is enough.