Table of contents

100 Prisoners with Red/Black Hats - Puzzle

The 100 prisoners and hats puzzle is one of the most famous logic riddles in the world. In this problem, 100 prisoners must guess the color of the hat on their head -red or black - without being able to see it. At first glance, it seems like pure luck, but with the right strategy, the prisoners can guarantee that at least 99 survive. This puzzle is popular in math competitions, brain teasers, and even tech interviews at companies like Google and Microsoft because it tests logical thinking, teamwork, and communication skills.  

100 Prisoners with Red/Black Hats

100 Prisoners Puzzle Setup and Rules

Here are the rules of the puzzle:

  • 100 prisoners are lined up in a single file.
  • Each wears a red hat or a black hat.
  • Every prisoner can see the hats in front of them, but not their own or those behind.
  • Starting from the prisoner at the back of the line, each must guess the color of their own hat.
  • Correct guess → survival. Wrong guess → execution.

The prisoners are allowed to plan a strategy beforehand.

The question: What is the best strategy to maximize the number of correct guesses?

How to Solve the 100 Prisoners Hat Puzzle ?

The winning approach relies on parity (even or odd numbers of red hats). With this method, the prisoners can work together so that 99 survive for sure, and sometimes all 100.

Step 1: Agreeing on the Strategy

Before the guessing starts, the prisoners decide that the last prisoner in line will announce whether the total number of red hats they see is even or odd.

Step 2: The 100th Prisoner’s Signal

  • If the number of red hats is even, they say “red.”
  • If it’s odd, they say “black.”

This signal encodes parity but doesn’t guarantee their own survival (50/50 chance).

Step 3: Deductions for the Remaining Prisoners

  • The 99th prisoner uses the parity information plus the hats they see in front.
  • Comparing the two, they can deduce their own hat color with certainty.
  • Every prisoner after that (98th, 97th, etc.) updates the parity and repeats the same logic.

Final Answer: Maximum Survivors in the 100 Prisoners Hat Puzzle

Using the parity method:

  • 99 prisoners are guaranteed to survive.
  • The 100th prisoner has a 50% chance.

That means at least 99 prisoners always survive, and in some cases, all 100 prisoners survive.

This puzzle has become a classic because it shows how teamwork and logic can solve impossible challenges. It is widely used in:

  • Job interviews at companies like Google and Microsoft.
  • Math Olympiads and competitions.
  • Logic puzzle books and riddles online.

It’s a brilliant example of how strategy and clever communication can save lives—even in a puzzle.

Similar Logic Puzzles with Answers

Here are other famous logic puzzles that, like the 100 prisoners puzzle, combine strategy and deduction:

1. The Blue Eyes Puzzle – Logic on an Island

Setup: On an island, no one knows their own eye color. A visitor says, “At least one of you has blue eyes.”
Answer: If n people have blue eyes, they all leave on the nth night once they figure it out.

2. The Two Doors Riddle – Truth and Lies

Setup: Two guards protect two doors: one safe, one deadly. One guard always lies, the other always tells the truth. You can ask one question.
Answer: Ask either guard, “If I asked the other guard which door leads to freedom, what would he say?” Then choose the opposite door.

3. The Pirates and Gold Coins Puzzle – Greedy but Logical

Setup: Five pirates must divide 100 gold coins by vote. Rejected proposals lead to mutiny.
Answer: The senior pirate takes 98 coins, gives 1 coin to two others (to secure votes), and survives with most of the treasure.

4. The Monty Hall Problem – Should You Switch?

Setup: You pick one of three doors: behind one is a car, the others hide goats. The host reveals a goat behind another door. Do you switch?
Answer: Yes. Switching increases your chance of winning from 1/3 to 2/3.

5. The 3 Prisoners Problem – Changing Odds

Setup: Three prisoners, two will be executed. One asks a guard to name another who will be executed. The guard does so - does this change his odds?
Answer: No. His chance of survival remains 1/3, not ½.

The 100 prisoners hat puzzle solution shows that smart strategies can beat impossible odds. By using parity, the group ensures 99 prisoners always survive, and sometimes all 100 make it out alive.

And if you enjoyed this riddle, try the similar logic puzzles above - each one will challenge your brain and sharpen your problem-solving skills.

Puzzles

Related Articles