To save butting in on the other older riddle post once again (especially seeing as I don't really known the 'right answer') I posted this one alone. I heard this some time ago, but could never come to terms with the answer. Can you?
Four prisoners are about to be executed. Two are wearing white hats, and two are wearing black ones. No one knows which hat he is wearing. One of the prisoners is standing alone in a separated room. The other three are standing in line in another room: The first of them is facing the wall, the second is facing the back of the first one (so he can see his hat), and the third one is facing the back of the second (so he can see both the first's and the second's hat).
The guards tell all four prisoners that if they can guess their hat's color, they'll be free, but if they guess wrong they will go through horrible tortures before death. One of the prisoners will walk free for sure - who is it and why?