Question: http://good-interview-puzzles.blogspot.com/2011/08/puzzle-prisoners-and-five-hats.html
The solution
Assuming that A wears a black hat.
• If B wears a black hat as well, C can immediately tell that he is wearing a white hat after looking at the two black hats in front of him.
• If B does not wear a black hat, C will be unable to tell the colour of his hat (since there is a black and a white). Hence, B can deduce from A's black hat and C's response that he (B) is not wearing a black hat (otherwise the above situation will happen) and is therefore wearing a white hat.
This therefore proves that A must not be wearing a black hat.
The solution
Assuming that A wears a black hat.
• If B wears a black hat as well, C can immediately tell that he is wearing a white hat after looking at the two black hats in front of him.
• If B does not wear a black hat, C will be unable to tell the colour of his hat (since there is a black and a white). Hence, B can deduce from A's black hat and C's response that he (B) is not wearing a black hat (otherwise the above situation will happen) and is therefore wearing a white hat.
This therefore proves that A must not be wearing a black hat.