#398
One Hundred Hats in a Line
Also asked as: The 100 hats problem · the prisoners and hats puzzle · hat colour guessing strategy
One of the classic quant interview questions, free to read in full.
MediumBrainteasers & Logic
Problem
100 prisoners stand in a line, each wearing a red or blue hat assigned adversarially. Each sees every hat in front of them, none behind, not their own. From the back of the line forward, each must say a single word, "red" or "blue," heard by all; those who name their own hat color are freed. The team strategizes beforehand. How many can be guaranteed freed?
Your answer
Accepts decimals, fractions (5/12), and percentages (25%).