puzzle
LOGIC PUZZLE TIME!
This is one of my favorite puzzles, both because the answer isn't easy, and because the setup is very similar to another problem a lot of people know.
You and two other prisoners are set to be executed. You're given one chance to get out, by some sadistic game invented by your captors. (Isn't that how it always is?)
You're each privately given a hat, which is either red or blue (randomly chosen, independent of the hats chosen for the other people). You can't see your own hat. Once you're all wearing the hats, you're ushered into a common room where you can see the other two people and their hats. Without being allowed to communicate, you're then sent back to your solitary confinement and your hats are removed.
Each of you is then given a piece of paper to write down your hat color. You may either write "red", write "blue", or leave the paper blank. If any of you guess wrong, or if you all leave your papers blank, then you're all executed. But if even one of you guesses right, without any wrong guesses, you're all set free.
If you are allowed to discuss strategy among the three of you before the hats are handed out, but you're allowed no communication during or afterwards, what is the optimal strategy? In other words, what should you do such that you all have the best chance of survival? (The answer is "legit", assuming no wording loopholes, no color-blindness, no sympathetic guards, and nothing else like that.)
(Comments to this post are screened, but only correct answers and really good guesses will remain screened. I'll unscreen questions, comments, wrong answers...almost everything except correct answers. Eventually, I'll unscreen everything.) EDIT: Comments now contain spoilers.
This is one of my favorite puzzles, both because the answer isn't easy, and because the setup is very similar to another problem a lot of people know.
You and two other prisoners are set to be executed. You're given one chance to get out, by some sadistic game invented by your captors. (Isn't that how it always is?)
You're each privately given a hat, which is either red or blue (randomly chosen, independent of the hats chosen for the other people). You can't see your own hat. Once you're all wearing the hats, you're ushered into a common room where you can see the other two people and their hats. Without being allowed to communicate, you're then sent back to your solitary confinement and your hats are removed.
Each of you is then given a piece of paper to write down your hat color. You may either write "red", write "blue", or leave the paper blank. If any of you guess wrong, or if you all leave your papers blank, then you're all executed. But if even one of you guesses right, without any wrong guesses, you're all set free.
If you are allowed to discuss strategy among the three of you before the hats are handed out, but you're allowed no communication during or afterwards, what is the optimal strategy? In other words, what should you do such that you all have the best chance of survival? (The answer is "legit", assuming no wording loopholes, no color-blindness, no sympathetic guards, and nothing else like that.)

no subject
(Anonymous) 2006-01-25 06:05 am (UTC)(link)You mean if any guesses wrong you all die, but if every one of you guesses right you're all set free?
no subject
no subject
Fallacy.
If any one of us guesses wrong, we're all killed, but if one of us guesses right, we all live? That makes no sense. If one of us guesses right, one of us guesses wrong, and one of us leaves our paper blank then we all die because of the one wrong guess, but we all live because of the one right guess.
Or does it mean that if one person gets it right and the other two don't answer then we all live?
no subject
if (wrong_guesses > 0) { # blank answers don't count as wrong guessesdie();
} else if (right_guesses > 0) {
live();
} else { # if every paper is blank
die();
}
no subject
no subject
but really, it doesn't need to be that complicated at all. if one or more of the three gets it right, they live. wrong vs. blank is irrelevant.
if (right_guesses > 0) {
live();
}
no subject
no subject
But then I worked out all the possibilities...
Everybody tells each other that if you see two people with different color hats, leave your paper blank. However, if you see the two others with the same color, guess the opposite.
Is this right?
no subject
no subject
You never said that all of the prisoners were not wearing the same coloured hats.
no subject
no subject
1) Two hats are the same and one is different. This means that only one person will fill out the paper.
2) Three hats are the same. This means that all of them will include an answer.
Now, the person that sees both hats of the same color can either decide that his hat is the same as theirs or is the other color. In the first scenario, the odds that he'll be right are 50/50, but in the second scenario it is clear that each person ought to say that his hat is the same color as the two that he sees. Because none of the people can determine which of the two scenarios is the case, it is to the person's advantage that sees two hats of the same color to guess that his hat is the same as theirs. I think.
no subject
no subject
no subject
no subject
--Jeff
no subject
no subject
--Jeff
no subject
no subject
(1) If you see one red hat and one blue hat, leave your paper blank.
(2) If you see two red hats or two blue hats, write down the color you don't see.
Example:
(r) A sees r and b
(b) B sees r and r
(r) C sees b and r
B will write down blue, and A and C will leave blank sheets. They all walk.
(r) A sees r and r
(r) B sees r and r
(r) C sees r and r
A,B,C will all write down blue and be executed.
1/4 of the time, all the hats will be the same color. Then by (2) everyone will write down the wrong color and be executed.
3/4 of the time, there will be two hats of one color and one hat of the other color. By (1), the people with the same color hats will leave blank papers and by (2), the person with with the different color will answer correctly.
I believe that this strategy is optimal. Here's why.
Suppose that upon seeing two same-color hats, I write down the color I don't see with probability p and the color I do see with probability 1-p. Then
p*(3/4) + (1-p)*(1/4)
of the time, we are set free. However,
p*(3/4) + (1-p)*(1/4) = 1/4 + p*(1/2)
1/4 + p*(1/2) is largest when p = 1, i.e. the strategy initially described.
I have a modification. One person of the three can ask the executioner one question. It is known that the executioner either always tells the truth or always lies. What is the optimal strategy now?
no subject
no subject
and no allowed communication- does that mean that they're watching us for hand motions, etc.
if there can't be 3 hats of the same color then it would all be very easy, and the only person who should write down their color would be someone who sees the other 2 wearing the same color hats, thus they have the other color.
but i guess that doesn't work here. that would be too easy. but the way you word it, there isn't a set way to win, because really there is a chance that you all get the same color hat.
ok. 2*2*2=8. 8 combinations of hat
RRR
RRB
RBR
RBB
BRR
BRB
BBR
BBB
6 out of 8 of those combinations are 2 and 1. So therefore, I think the optimal solution is that you should only write your color if you see the other 2 wearing the same color. you have a 3/4 chance of winning.
i have no clue what to do in the other case, but you said optimal solution.
no subject
no subject
the only thing that would work for all 3 being the same would be some covert signal, like some way they could say if they were going to write. if they could do that, and see that all 3 of them were going to write, then they would realize they all had the same color. but that might be cheating.
no subject
no subject
Solution?
Beforehand they agree that P1 will guess p2's color, p2 guesses p3's color, and p3 guesses p1's color. Is that right?
Re: Solution?
Re: Solution?
no subject
no subject
no subject
no subject
no subject
no subject
no subject
no subject
oh wait that would be fishy if they all got it right, so only one of them should actually write the right color.
no subject
no subject
The optimal solution is related to something called Hamming Codes. The general answer to the problem, when N is one less than a power of 2 (e.g. 3, 7, 15, 31, etc.) involves using "Hamming Codewords". See http://www.ee.unb.ca/tervo/ee4253/hamming.htm, the section entitled "sixteen valid codewords". The correct solution for 7 people involves assigning everyone a number 1-7, and having everyone memorize these 16 codewords (where 0 is red and 1 is blue). Then, if the hats the other 6 people are wearing correspond to one of the codewords (with only your hat as an unknown), you guess the hat color which would make the overall distribution a non-codeword. Because of the way the codewords are arranged, that means that about 94% of the time, one person will guess the right color and the group will win, and 6.25% of the time (when the distribution is exactly a codeword), everyone will guess wrong. Read the rest of that link to try to figure out why it works.
no subject
And haming codewords wouldn't be kosher anyways
*Ducks* [that was an A worthy pun, I probably shout be hit at some point]
no subject
red red red
red red blue
red blue red
red blue blue
blue blue blue
blue blue red
blue red blue
blue red red
there!
and doesn't "blue" look funny after reading it a lot?