Thursday, May 15, 2008 - 11:38 pm

Logic Puzzle: Red Hats, Green Hats

Here's another logic puzzle.
10 prisoners are about to be executed. The executioner decides to give them a chance for freedom. He will put either a red hat or a green hat on everyone's head. Then, they're required to line up in a row. The executioner will then start with the last prisoner at the back, asking him to guess the colour of his hat. If he gets it wrong, he'll be shot on the spot. If he guesses correctly, he'll be allowed to go freely. Then, the executioner continues down the row and so on.

Before the executioner puts the hats on them, the prisoners're given a chance to discuss among themselves and come up with the best way to increase their chances of survival.

What is the best way the prisoners can come up with? And what is the chance of survival for each of them?

Clarification:
  • It is known that out of the ten hats, there must be at least a red hat, or at least a green hat.
  • The prisoners are lined up in a row, so that each of them can only see the hats of the prisoners in front of him, but not of those behind him.

7 comments:

Wei Zhi said...

hmm.. for my answer i am assuming that they are free to choose the place they stand in the line.

First thing, everyone assumes they have red hats. Then everyone starts the lining up process one buy one.
The rule for lining up is move in front of the person if you see a green hat in front of you.

this way, everyone can determine the color of their hats. (The first person can tell if he has a green hat too if the guy behind him moves up and stand in front of him again after the initial swap.)Once the first two guys know the color of their hats, the rest can be easily taken care for.

well i hv assumed that they can switch places too since it is their way to do it lol.

Kryptos said...

good try, but unfortunately, the executioner lines them up. otherwise, it'd be too easy :D

Wei Zhi said...

aww wth can't it juz go my way? lol
aihz... i will think again when i hv time haha

Kryptos said...

just to confuse u more, the same method works even when there're three colours or more. i'm not gonna tell u how many prisoners can survive tho. :P

just take your time. it took me a while to figure this one.

Wei Zhi said...

ok i will ask u to be clear first b4 i think of all that odd shit... r they allowed to communicate in any form once they line up? (i guess its a stupid question but i like to take chances :P)

Kryptos said...

of course, no form of communication between prisoners is allowed after the hats are put on.

the executioner walks down the row and asks one prisoner at a time to make a guess. it is possible for everyone else to overhear the answer. n if a prisoner makes a wrong guess, he'll be shot right on the spot. obviously, d other prisoners can tell that from the gunshot.

i think tat's all tat need to be clarified. they may not necessarily have anything to do with d answer though.

Anonymous said...

The first guy to guess his hat counts the number of red hats. If the number is even, he says "red", otherwise he says green. Now the second guy knows that if the number of hats he sees is even, he has a green hat, and if the number of red hats is odd he has a red hat. And so on...

How about with four color hats? Red, Green, Blue, and Black?