Learn / Library / Brainteasers
Parity announcements in a row
The warden gives each of prisoners a red or a blue hat, all colour patterns equally possible. The prisoners stand in a line facing the same way and each sees every hat in front of them but not their own or those behind. Each prisoner announces a colour by this fixed rule: say red if the number of red hats in front of you is even, otherwise say blue. For how many of the patterns are exactly of the announcements correct?
Checking an answer needs JavaScript. The hint and the solution open without it.
Hint
Fix the hats from the front of the line backwards. Given the hats in front of a prisoner, how many of the colours make his announcement correct?
Solution
- Choose the hats from the front prisoner backwards. Once the hats in front of a prisoner are fixed, his announcement is fixed, so exactly of his possible colours makes it correct.
- So each pattern gives exactly one pattern of right and wrong announcements, and every right-or-wrong pattern for the prisoners occurs exactly once.
- The patterns with exactly correct announcements correspond to choosing which of the prisoners are right, which gives choices.
- Hence the number of patterns is .
Answer: