Prisoners in a line with hats

Published , last checked . Re-solved cold against the published wording before it went live: how puzzles and answers are checked.

They hear one letter, then each must guess. How do they save almost everyone? From the free puzzle set on Think Fanny. Next try Three switches, one bulb.

Think Fanny strategy and logic puzzle scene over a chess board

The puzzle

One hundred prisoners stand in a single-file line. Each gets a black or white hat at random. Every prisoner can see all the hats in front of them, but not their own or any behind.

Starting from the back of the line, each prisoner must say either “black” or “white”. Everyone hears every guess. They may plan a strategy before the hats are placed, but not after.

How can they guarantee that 99 prisoners are saved, with only the back prisoner at risk?

The parity trick, written up elsewhere

One bit of information does all the work in this puzzle, and that bit is parity. Both ideas are documented well outside this site:

If one of these contradicts the answer above, we would rather hear it than not. See how puzzles and answers are checked.