One hundred prisoners are standing in a straight line, all facing the same direction.
- Each prisoner is wearing a hat that is either red or black.
- Every prisoner can see the hats of all prisoners standing in front of them, but not their own hat or those behind them.
- The prisoners will be questioned one by one, starting from the last person in the line (who can see all others) and moving forward.
Rules:
- Each prisoner must state the colour of their own hat.
- If the guess is correct, the prisoner survives.
- If the guess is incorrect, the prisoner is executed.
- Before the process begins, the prisoners are allowed to discuss and agree on a strategy.
- Once the questioning starts, no communication is allowed, except for stating “red” or “black”.
What strategy should the prisoners adopt to maximise the number of survivors, and how many prisoners can be guaranteed to survive?

Check if you were right - full answer with solution below.
Solution:
A maximum of 99 prisoners can be guaranteed to survive by using a parity-based strategy.
Step 1: Signal by the Last Prisoner (100th)
- The last prisoner counts the number of red hats in front.
- If the count is even, he says “Red”.
- If the count is odd, he says “Black”.
This announcement encodes the parity (even/odd) of red hats.
His own survival is uncertain (50% chance), as he is only passing information.
Step 2: Information Available to Others
Each subsequent prisoner has access to:
- The initial parity signal
- The answers have already been spoken
- The hats visible in front
Step 3: Deduction Process
- Each prisoner uses the expected parity given by the first prisoner.
- Each prisoner counts the number of red hats visible ahead and the number of red hats confirmed from previous answers.
- Each prisoner compares the observed parity with the expected parity.
- If both match, the prisoner concludes their hat is black.
- If they do not match, the prisoner concludes their hat is red.
Result
- The first prisoner may be incorrect.
- The remaining 99 prisoners are guaranteed to be correct.