As long as we’re on the topic of solutions, here’s the answer to the Prisoners & Hats brain teaser of a few days ago. Or, I’ll start with a hint, rather, and if you want to stop after reading the hint and not read the solution until you’ve had some time to think about it, then you can. Or if you want to stop now and read the brain teaser again, do that.
Anyway, here’s the hint. I’ll tell you first that all of the prisoners in line will give the correct answer and live, except for the one at the back of the line (who is asked the question first). Obviously he can’t know the color of his own hat and so has a 50% chance of getting it right.
Given that the rest of the prisoners live, each MUST state the color of his own hat and nothing else. So you know what each prisoner says, the only thing you don’t know is what the first-asked one says to start off the chain.
Here’s the answer:
The last in line (asked first) prisoner counts the number of, say, white hats on all the 99 prisoners in front of him. It’s either even or odd, and he says black or white, respectively. He has a 50% chance of dying because he has no info about his own hat. The next in line counts the number of white hats on the 98 prisoners in front of him to determine his own color. For example, if it’s even and the guy behind him said white, he knows he must have a white hat.
Now each prisoner, when asked, has counted the number of known white hats in front of him visually and behind him auditorially. He gets an even (->black) or odd (->white) total from those 98 others. The first-asked person could see 99 others. So for each prisoner N, if he gets a different answer from that of the first guy, he says “white”, and if he gets the same answer he says “black”.