Analytical Interview Questions
Home C/C++ JAVA Google Microsoft Data structures Puzzles Google
Pages
Resume Tips

 

Question

There was a sheriff in a town that caught three outlaws. He said he was going to give them all a chance to go free. All they had to do is figure out what color hat they were wearing. The sheriff had 5 hats, 3 black and 2 white. Each outlaw can see the color of the other outlaw’s hats, but cannot see his own. The first outlaw guessed and was wrong so he was put in jail. The second outlaw also guessed and was also put in jail. Finally the third blind outlaw guessed and he guessed correctly. How did he know?

Solution

Let us look at it this way. Here are our possibilities:

1) BBB

2) BBW

3) BWB

4) WBB

5) WWB

6) BWW

7) WBW

Now we can eliminate # 6 because in this case the first outlaw would be sure to know that he had on a black hat. # 7 can be eliminated for the same reason for the second outlaw’s guess.

In # 2, the first outlaw has to see at least 1 black hat (if he saw two while hats he wouldn't have guessed wrong). From this we know that outlaw 2 or outlaw 3 has a black hat (possibly both). Now outlaw 2 has the same dilemma, but he knows that one or both of outlaw 2 and 3 has a black hat. He can see that outlaw 3 has a white hat so in that case he would guess black and be correct, but he didn't (since we know he guessed wrong). Given this, we can remove option 2 from consideration.

Options 1,3,4,5 all have outlaw 3 wearing a black hat. Thus, assuming that convicts 1 and 2 are as logical as possible, the only options left all have outlaw 3 wearing a black hat.

 

Recommended Materials

 

Keywords: