The game where the last one's sacrifice-that-isn't saves everyone.
You cannot see your own hat — only the hats ahead of you. Is there a way for all six to survive?
The hats' answer is carried by parity, not by eyes.
Experiment
Hands-on experiment
🎩 Jump in! Six prisoners stand in a line. Each sees only the hats ahead. From the back forward, each states their own hat color (those ahead can hear it). Pick all six answers yourself. A correct answer survives!
Now answering: #6 (rearmost) — 5 hats visible ahead
📖 Read more — why it exists · insights · common mistakes · formulasExpand ▾
Why
Why does this exist?
Six people stand in a line. Each hat is black or white at random. Everyone sees only the hats in front of them, and from the back forward, each must state their own hat color. Those ahead can hear each answer.
Eyes alone can never solve it — your own hat sits outside your view. Yet with a single agreement, everyone except the rearmost survives with certainty. That agreement is odd-versus-even: what mathematics calls parity.
Parity is the smallest information checker there is. ID-number check digits, barcode check digits, and memory error detection all run on the same principle as this puzzle. It is logic saving lives.
Insight
Insights from the video
“One spoken word can carry one bit.”
The rearmost prisoner's 'black' is not about his own hat. It is a parity summary of all five hats ahead. Borrowing the format of an answer to send different information — the first step of encoding.
“Parity is a promise that shows when broken.”
Know the total parity, subtract what you see and what you heard, and what remains is your own hat. If anything is off, the parity fails to balance. That sensitivity is how error detection works.
Misconception
Common misconceptions
There is no information about my own hat, so everyone must guess.
Nobody sees your hat, but a spoken word can carry information. If the rearmost calls the parity of the black hats he sees instead of guessing, that one word becomes the key for all five in front.
The rearmost prisoner is sacrificed for the team.
His survival chance stays at 50% — it was 50% anyway, strategy or not. He loses nothing while making five certain. Not a sacrifice; a free gift.
Formula
Writing it as math
The whole strategy compresses into one subtraction: from the total parity the rearmost announced, subtract the black hats your eyes see and the black answers your ears heard. The leftover parity is your hat.
🔬 Formula anatomy — the subtraction that saves five
= − −
The rearmost's promise
Odd black hats: call 'black'. Even: call 'white'. He borrows the format of an answer to broadcast the total parity.
Everyone's computation
Subtract what you see and what you heard from the total parity, and your own hat remains. The later your turn, the more you have heard — the equation always closes.
The survival count
However many prisoners, only the rearmost rides on luck. A hundred prisoners: 99 certain. The cost stays at one.
In Real Life
Where you meet it in real life
ID-number check digits
The last digit of many national ID numbers is computed from the others by a fixed rule. Mistype one digit and the equation fails instantly.
Barcode check digits
If the checksum fails, the scanner re-reads instead of beeping. Checkout-counter error detection runs on the prisoners' parity.
Parity bits in memory
Computers store one extra parity bit with the data. Even a cosmic ray flipping one bit gets caught at the check.
Credit card validation
The final digit of a card number is a check digit too. Mistyped numbers get filtered before any payment starts.
Practice
Practice — conquer the types
✏️ 4 practice problems — solve to conquerTap to solve ▾
With the parity strategy, how many of the six survive for certain?
What does the rearmost prisoner call out?
With 100 prisoners, how many survive for certain?
The rearmost called 'odd black'. The next prisoner sees 2 black hats ahead. His own hat is:
Watch
Related video
Connection
Concepts connect
Previous concept
The Poisoned Wine
You counted information with mice; now load information onto a single word.
← The Poisoned Wine labLeads to next
Sets & Logic
The parity logic that saved lives, now learned as mathematics' grammar.
Go to the Sets & Logic lab →Related
Labs worth exploring together
Related lab
Sets & Logic
Parity reasoning as grammar — the world of propositions that are true or false.
Go to the Sets & Logic lab →Related lab
Probability
Why the strategy-free game lands at exactly 50%, in probability's own language.
Go to the Probability lab →