Oh sorry guys.
"and say aloud to the jailer what colour hat
he has on his head
all four prisoners go free."
i realise this could sound a little ambiguous but it's actually not suppose to be. There is only one of the prisoners that is able to be 100% sure of what colour hat he himself is wearing. You can count out D as he is in the room on his own and can't be seen or see anyone else.
I'll post the lot again so people don't have to find the original post.
four prisoners are arrested for a crime, but the jail is full and the jailer has nowhere to put them. He eventually comes up with the solution of giving them a puzzle so if they succeed they can go free but if they fail they are executed.
The jailer puts three of the men sitting in a line. The fourth man is put in a seperate room and he gives all four men party hats (as in diagram). The jailer explains that there are two red and two blue hats. The prisoners can see the hats in front of them but not on themselves or behind. The fourth man in the room can't see or be seen by any other prisoner. No communication between the men is allowed.
the jailer tells them that if one of them can answer difinitively (no guessing allowed) and say aloud to the jailer what colour hat he has on his head
all four prisoners go free.
http://img258.imageshack.us/img258/9933/hats.png