My Favorite Riddle
#1
Posted 2007-November-07, 13:28
The executioner then outlines his plan whereby he will line the dwarves up in a straight line, each facing the same direction, so that each dwarf can see all the dwarves in front of him (if he pokes his head out) but cannot see anyone behind him, nor is he allowed to turn around. The executioner then puts either a red or a black cap on each dwarf entirely at random (there does not need to be an equal number of black or red caps) and proceeds from the back of the line to the front of the line and asks each dwarf in turn what color their cap is. If they guess correctly, they live. If they guess incorrectly, they die (by beheading... an axe).
The dwarves get together and figure out a way so that - given this information - 9/10 of the dwarves are guaranteed to survive this ordeal.
When the executioner asks the first dwarf the color of his cap, what must he say? The inflection of his voice plays no part in the solution and he is only allowed to say either "red" or "black". Each dwarf can hear what all the other dwarves behind them say.
#3
Posted 2007-November-07, 14:04
#4
Posted 2007-November-07, 14:07
I'm offended you chose to execute dwarves in your story. They are distant cousins of gnomes, however they always seem to be getting into trouble.
#5
Posted 2007-November-07, 14:15
So many experts, not enough X cards.
#6
Posted 2007-November-07, 14:18
#7
Posted 2007-November-07, 14:29
helene_t, on Nov 7 2007, 03:18 PM, said:
No, because the next to the last dwarf has to say "red or black".
The last dwarf says, "Black" for the guy in front of him. He lives or dies depending on how lucky he is.
Now the next to the last dwarf knows what color he has, so he will live by saying the same thing the last dwarf did. But he can't also tell the one in front of him what color he has.
Now the third from the last dwarf is back to naming the color of the guy in front of him.
The most you could save with certainty under this scenario is 5.
10 lives or dies (names color of guy in front of him, hopes he has same color),
9 lives (names his color),
8 lives or dies (names color of guy in front of him, hopes he has same color),
7 lives (names his color),
6 lives or dies (names color of guy in front of him, hopes he has same color)
and so on.
So many experts, not enough X cards.
#8
Posted 2007-November-07, 14:47
I agree with bid's analysis. I don't see how it's remotely conceivable to save more than 5 with certainty. You can either save yourself (which conveys no helpful information to your buddies) or you can tell the guy in front of you how to save himself (which means you have only a 50-50 shot of surviving yourself.) There's surely no way to guarantee that the front 9 dwarves all live.
I'm 99.999% sure that either the problem was posed incorrectly or that there's some cheesy 'solution' that violates the parameters of the problem (since it's not explicitly stated that a dwarf can't take off his own cap and look at it.)
#9
Posted 2007-November-07, 14:52
jonottawa, on Nov 7 2007, 12:47 PM, said:
I agree with bid's analysis. I don't see how it's remotely conceivable to save more than 5 with certainty. You can either save yourself (which conveys no helpful information to your buddies) or you can tell the guy in front of you how to save himself (which means you have only a 50-50 shot of surviving yourself.) There's surely no way to guarantee that the front 9 dwarves all live.
I'm 99.999% sure that either the problem was posed incorrectly or that there's some cheesy 'solution' that violates the parameters of the problem (since it's not explicitly stated that a dwarf can't take off his own cap and look at it.)
That's not true. You can save all of the dwarves bar the first one. Furthermore, you could do so even if there were more colors. Keep thinking about it. As a start, imagine there were 3 dwarves. Could you save 2 for sure?
#10
Posted 2007-November-07, 14:58
jonottawa, on Nov 7 2007, 03:47 PM, said:
I agree with bid's analysis. I don't see how it's remotely conceivable to save more than 5 with certainty.
<snip>
I'm 99.999% sure that either the problem was posed incorrectly or that there's some cheesy 'solution' that violates the parameters of the problem (since it's not explicitly stated that a dwarf can't take off his own cap and look at it.)
What bid_em_up posted was not his analysis of the problem. I think he was responding to helene's post. I don't think bid_em_up ever claimed that 5 is max. I might be mistaken though, but it does look like he is talking about helene's solution.
Let me assure you, there is no "cheesy" solution to this. It is a very legitimate answer and is very clever. All but one can survive, even with more than 2 colours.
[edit] Gnome beat me to it [/edit]
#11
Posted 2007-November-07, 15:02
Echognome, on Nov 7 2007, 08:52 PM, said:
jonottawa, on Nov 7 2007, 12:47 PM, said:
I agree with bid's analysis. I don't see how it's remotely conceivable to save more than 5 with certainty. You can either save yourself (which conveys no helpful information to your buddies) or you can tell the guy in front of you how to save himself (which means you have only a 50-50 shot of surviving yourself.) There's surely no way to guarantee that the front 9 dwarves all live.
I'm 99.999% sure that either the problem was posed incorrectly or that there's some cheesy 'solution' that violates the parameters of the problem (since it's not explicitly stated that a dwarf can't take off his own cap and look at it.)
That's not true. You can save all of the dwarves bar the first one. Furthermore, you could do so even if there were more colors. Keep thinking about it. As a start, imagine there were 3 dwarves. Could you save 2 for sure?
No, you couldn't save 2 for sure.
I'm the guy at the back of the line. Nobody can see my cap. So you definitely can't save me for sure.
The guy in front of me has a black cap. If I don't tell him that he has a black cap you definitely can't save him for sure.
So I say 'black'.
I have a red cap and die. (Or if our code was to say the opposite of what he has on, I say 'red' and have a black cap and die.)
He says 'black' and lives.
Now the guy in front of him is on a pure guess and can't be saved for sure.
I really hope I'm wrong here. I love being outsmarted (or outclevered, perhaps.) But assuming there's not some cheesy 'cheat' (like looking at your own cap or the executioner cutting off his own head if you say black or some such nonsense) then it can't be done.
#12
Posted 2007-November-07, 15:04
Let's start with 3 dwarves and 2 colors.
Our dwarf at the end of the line is Mr. Altruistic. He is only going to call out a color in an attempt to save the lives of the other two dwarves. If the dwarves in front of him have on the same color hat, he says "Black". If they have on different colored hats, he says "Red".
Take it from there...
#13
Posted 2007-November-07, 15:14
it can be generalized to k colors and n-1 saved from n
George Carlin
#14
Posted 2007-November-07, 15:56
jonottawa, on Nov 7 2007, 03:47 PM, said:
I agree with bid's analysis. I don't see how it's remotely conceivable to save more than 5 with certainty. You can either save yourself (which conveys no helpful information to your buddies) or you can tell the guy in front of you how to save himself (which means you have only a 50-50 shot of surviving yourself.) There's surely no way to guarantee that the front 9 dwarves all live.
I'm 99.999% sure that either the problem was posed incorrectly or that there's some cheesy 'solution' that violates the parameters of the problem (since it's not explicitly stated that a dwarf can't take off his own cap and look at it.)
It wasnt so much an analysis as an explanation of why each dwarf couldnt just say what the one in front of him has on, as Helene appeared to be suggesting.
See the hidden text in jtfanclubs post for the solution to saving 9/10.
(And be prepared to be "outsmarted" when you do.)
Actually, I'm not sure his solution works either. What if there is an uneven number of black hats vs. red hats? ie. 7 blacks vs. 3 reds originally. Does it still work?
So many experts, not enough X cards.
#15
Posted 2007-November-07, 16:01
Echognome, on Nov 7 2007, 09:04 PM, said:
Let's start with 3 dwarves and 2 colors.
Our dwarf at the end of the line is Mr. Altruistic. He is only going to call out a color in an attempt to save the lives of the other two dwarves. If the dwarves in front of him have on the same color hat, he says "Black". If they have on different colored hats, he says "Red".
Take it from there...
Wow. Neat. Outclevered indeed. That gets you up to 1 dwarf saving 2. I'm still too dense to see how that gets you all the way down the line (1 dwarf saving 9.)
First guy says black (next 2 have same color) he has a red cap and dies.
Second guy sees that guy in front of him is red. He knows it's the same color as his cap. He says red. He has a red cap and lives.
Third guy knows that his cap is red because the first guy said he had on the same cap as the 2nd guy. He says red. He has a red cap and lives.
I'm the 4th guy. What color's my cap? What do I say?
With that last bit of foot-inserting into mouth, I am off to google the solution. Thanks for the puzzle.
#16
Posted 2007-November-07, 16:04
bid_em_up, on Nov 7 2007, 09:56 PM, said:
jonottawa, on Nov 7 2007, 03:47 PM, said:
I agree with bid's analysis. I don't see how it's remotely conceivable to save more than 5 with certainty. You can either save yourself (which conveys no helpful information to your buddies) or you can tell the guy in front of you how to save himself (which means you have only a 50-50 shot of surviving yourself.) There's surely no way to guarantee that the front 9 dwarves all live.
I'm 99.999% sure that either the problem was posed incorrectly or that there's some cheesy 'solution' that violates the parameters of the problem (since it's not explicitly stated that a dwarf can't take off his own cap and look at it.)
It wasnt so much an analysis as an explanation of why each dwarf couldnt just say what the one in front of him has on, as Helene appeared to be suggesting.
See the hidden text in jtfanclubs post for the solution to saving 9/10.
(And be prepared to be "outsmarted" when you do.)
Actually, I'm not sure his solution works either. What if there is an uneven number of black hats vs. red hats? ie. 7 blacks vs. 3 reds originally. Does it still work?
That is TOO cool. Great puzzle.
#17
Posted 2007-November-07, 16:14
jonottawa, on Nov 7 2007, 03:47 PM, said:
I agree with bid's analysis. I don't see how it's remotely conceivable to save more than 5 with certainty. You can either save yourself (which conveys no helpful information to your buddies) or you can tell the guy in front of you how to save himself (which means you have only a 50-50 shot of surviving yourself.) There's surely no way to guarantee that the front 9 dwarves all live.
I'm 99.999% sure that either the problem was posed incorrectly or that there's some cheesy 'solution' that violates the parameters of the problem (since it's not explicitly stated that a dwarf can't take off his own cap and look at it.)
When all the hats are just red or black it is easy if you have any experience with error correction codes or thinking in binary.
You can generalize to K colors as long as all the dwarfs know the value of K and are decent/good at math (to generalize to the K value one
#18
Posted 2007-November-07, 16:17
bid_em_up, on Nov 7 2007, 01:56 PM, said:
It works for any number of hats, the solution was just stated slightly incorrectly.
Anyone want to try to figure out the strategy for three colors? As a hint, the last guy in line can shout out any of three colors instead of two.
I'll leave it as hidden for those that want to work out the two color example on their own:
#19
Posted 2007-November-07, 17:26
bid_em_up, on Nov 7 2007, 04:56 PM, said:
Actually, I'm not sure his solution works either. What if there is an uneven number of black hats vs. red hats? ie. 7 blacks vs. 3 reds originally. Does it still work?
It's just odd-even. Black if the number of black caps is odd, Red if the number of black caps is even.
Much tougher with 3 colors. Offhand, I don't see how to do that. Hmmmm...
Suppose you have 9 caps. Either all 3 will be odd, or two will be odd and one will be even. That's four odd/even states. How to get it down to 3....hmmm...
If all three are odd, then it's easy. If two are even and one is odd, then after one is removed you'll either have 3 even or two odd and one even. But if all 3 are even, it's guaranteed that it wasn't all three even to start with.
Hmmm...
So, if the last dwarf could announce "All the remaining are odd", that would solve it for the others.
If the last dwarf could announce "All the remaining are odd if we added these two colors" and named the colors, that would do it.
What if we double encoded it from the back...arrgh, too complex. Anybody else solve it for three colors without killing two dwarves?
#20
Posted 2007-November-07, 18:25