The Hat Line

Ten prisoners stand in a line, each wearing a random black or white hat, each seeing only the hats in front. From the back forward, each must call out a color; wrong guesses are fatal. No strategy can save the rearmost prisoner — yet one bit, spent perfectly, saves all nine others with certainty. This is an error-correcting code you can act out.

chapter
the warden's rules

No huddle, no plan. The warden deals black or white hats at random and calls the line from the back. You are #6: 5 hats visible ahead of you, 4 voices behind you, and not one thing about your own head. Say a colour.

A line of 10 prisoners, front at the leftStand in the shoes of prisoner 1#1Stand in the shoes of prisoner 2#2Stand in the shoes of prisoner 3#3Stand in the shoes of prisoner 4#4Stand in the shoes of prisoner 5#5Stand in the shoes of prisoner 6#6Stand in the shoes of prisoner 7#7Stand in the shoes of prisoner 8#8Stand in the shoes of prisoner 9#9Stand in the shoes of prisoner 10#10
front #1 at the left, rear #10 at the right; everyone faces ← this way. You are #6: you see the 5 hats ahead of you and nothing behind. Click any figure to stand in their shoes.
round
you survived 0/0the line survived 0/0

Start with the person nobody can help. The rearmost prisoner sees every other hat and hears nothing; their own hat is behind every eye in the room, and it was flipped at random after they were lined up. No agreement made the night before can tell them anything about it. Their guess is worth exactly zero to them — so stop trying to save them and spend it.

Spend it on what? On one fact about everything in front: the number of black hats, odd or even. That single word is heard by all 9 others. Now #9 subtracts what they can see from the announced total; the remainder is their own hat. They say it out loud — and in saying it they hand the same trick to #8, who now knows the announcement and one more hat.

Everyone from #9 to #1 is doing arithmetic, not guessing. They cannot fail. The only person who ever gambles is the one who was doomed anyway, and they gamble at the same 1-in-2 they started with.