A logic problem by Daniel Patten
Alan, Barry and Carl are lined up facing a wall in prison, and the guards them that they are going to place a hat on top of each of their heads; either white or back. There are a total of five hats; three black and two white. They are told if one of them can guess the color of his own hat, they will all be set free. Carl is at the back and can see the colors of Alan's and Barry's hats, Barry can see the color of Alan's hat, and Alan can see nothing. The hats are placed on their heads. Carl says 'I don't know the color of my hat'. After a few seconds, Barry says 'I always don't know the color of my own hat'. Alan then says, I know the color of my hat. He gives the correct answer, and the three men are released. What color hat was Alan wearing?