There are 100 prisoners, each of whom will be lined up in a single file.
- Every prisoner will have either a red or black hat placed on their head, but they cannot see the color of their own hat.
- Each prisoner can see the hats of all the prisoners in front of them but not those behind.
- Starting from the back of the line, each prisoner will be asked to guess the color of their own hat. If they guess correctly, they are safe; otherwise, they are executed.
Before the process starts, the prisoners can discuss a strategy to maximize the number of correct guesses.
Objective:
Devise a strategy that maximizes the number of prisoners who guess their hat color correctly.
Solution:
The key to solving this puzzle is to use a strategy based on parity (even or odd numbers of a specific color), which ensures that at least 99 prisoners guess their hat color correctly.
Step-by-Step Solution for 100 Prisoners with Red/Black Hats Puzzle:
Step 1: Define the Strategy Using Parity
The prisoners agree on a strategy where they use the concept of even and odd numbers of red hats. The strategy works as follows:
- The prisoner at the back of the line (the 100th prisoner) will declare whether they see an even or odd number of red hats in front of them. This prisoner may or may not guess their own hat color correctly, but their declaration will help the rest of the prisoners make correct guesses.
Step 2: The 100th Prisoner’s Guess
- The 100th prisoner counts the number of red hats they see in front of them:
- If the number of red hats is even, they say "red" (indicating they think their hat makes the total even).
- If the number of red hats is odd, they say "black" (indicating they think their hat makes the total odd).
The 100th prisoner may or may not guess correctly, but their statement will provide crucial information for the next prisoners in line.
Step 3: The Remaining Prisoners’ Strategy
Each subsequent prisoner uses the information provided by the prisoner behind them to deduce the color of their own hat.
- 99th Prisoner: The 99th prisoner knows how many red hats they see in front of them. Based on what the 100th prisoner declared (whether the total number of red hats behind them is even or odd), they can figure out their own hat color. For example:
- If the 100th prisoner said "even" and the 99th prisoner sees an odd number of red hats, then the 99th prisoner knows their hat must be red (to make the total even).
- If the 100th prisoner said "odd" and the 99th prisoner sees an odd number of red hats, their hat must be black.
- 98th Prisoner and Onward: The same logic applies to all remaining prisoners. Each prisoner can count the number of red hats in front of them and compare it with the previous prisoner’s declaration to deduce their own hat color.
Step 4: Guaranteed Correct Guesses
By following this strategy, 99 prisoners will always guess their hat color correctly, and the 100th prisoner has a 50/50 chance of guessing their own hat color correctly.
Final Answer
Using the strategy based on parity, at least 99 prisoners are guaranteed to guess their hat color correctly, and the first prisoner has a 50% chance of guessing correctly.