The guard said, "If anyone can tell me with absolute certainty the color of his own hat, you may all go free. However, under no circumstances may you communicate the color of anyone else's hat."
He first asked Albert. Albert is a very honest and intelligent (ie perfectly rational) person, but he was dumbfounded. "I don't know", he said, "there's no way of knowing."
He then asked Barry. Barry was equally intelligent and rational, but he also could not say.
The guard said, "I regret that I have to execute you three, but seeing as Carl is blind, he's not going to know. You have failed."
But Carl piped up and said, "But I do know the color of my hat."
What is the color of Carl's hat, and how did he know?
Solution courtesy of Andy Wright:
Albert is first to guess, he knows there are only two black hats. If
he sees the two black hats on Barry and Carl, then he knows his must
be white. However, he could not conclude what color his was,
therefore either Barry or Carl must be wearing a white hat.
Barry understands this. If he sees Carl wearing a black hat, then he
knows he must be wearing a white hat (regardless of what color Albert
is wearing). However, he also could not conclude what he was wearing,
so Carl must be wearing a white hat.
It's impossible to determine what color either of the other two are
wearing (they could both be wearing white, both be wearing black, or
one of each color).