# Five hats puzzle solution

If you haven’t read it yet, read the Five hats puzzle.

Recall that the warden has three white hats and two black hats. If the first prisoner, Art, saw two black hats, then he would know that he had a white hat. Art says he doesn’t know his hat color, so the other two prisoners must be wearing either at least one white hat.

Next if Billy saw Carter wearing a black hat, he would know that he (Billy) was wearing a white hat (because they are wearing at least one white hat). Billy says he can’t tell which color hat he is wearing, so that means Carter must be wearing a white hat.

Now Carter knows that he must be wearing a white hat so he says that he knows his hat color. (He’s not called “Clever Carter” for nothing.)

My the book Interview Puzzles Dissected not only describes similar hats puzzles (and lots of other kinds of puzzles) and their solutions, but it also discusses extensions to the puzzles. For example:

• What happens if Art can guess his hat color?
• What if there was only one black hat?
• What if there was no penalty for guessing incorrectly?
• What if there were four prisoners? How many black and white hats would you need for the last prisoner to figure out his hat color? Could the second-to-last prisoner figure out his color?

## About RodStephens

Rod Stephens is a software consultant and author who has written more than 30 books and 250 magazine articles covering C#, Visual Basic, Visual Basic for Applications, Delphi, and Java.
This entry was posted in books, games, puzzles and tagged , , , , , , , , , , , . Bookmark the permalink.

This site uses Akismet to reduce spam. Learn how your comment data is processed.