Four prisoners are buried in the ground to the height of the neck, which only sticks their heads to breathe. There is a wall that separates three of the prisoners from the room as shown in the drawing.
The jailer who is watching them tells them the following:
Each of you is wearing a hat on his head. Of the four hats, two are white and two are black. You have ten minutes for one of you to tell me what color his hat is. If you succeed you will all be free and if not, you will die shot.
Prisoners cannot communicate with each other and can only see what they have in front of them. Obviously no one can see over the wall or through it. Finally, after one minute, one of the prisoners manages to find out the correct answer.
Could you say which prisoner is the one who says the color of his hat and how has he known?
Prisoner C is right in his response by saying that his hat is black.
The reasoning is as follows. if prisoner D, who is immediately behind him has said nothing, it is because he sees that the two hats in front of him are of different colors and therefore he cannot know what color his is. So if prisoner C sees that B's hat is white and knows that D has not responded because he does not know the answer, it means that his hat can only be black.