The Alien Hat Riddle

A classic logic puzzle with an extraterrestrial twist

👾 The Scenario

An alien has captured 10 humans and lines them up single-file. Each person can see everyone in front of them, but nobody behind. The alien randomly places a black or white hat on each person's head. Starting from the back of the line, each person must guess the color of their own hat. They may only say "Black" or "White". Everyone hears every guess. Guess wrong and the alien eats you. But the humans have a secret strategy that guarantees at least 9 out of 10 survive...
Normal
Saved
-
Eaten
-
Round
0

🎩 The Line

← Back (guesses first) Front (guesses last) →

🔢 Parity Tracker

Running parity of black hats: --
Black hats seen ahead: --

🧠 Reasoning

Click "Next Step" or "Play All" to begin the walkthrough.

💡 Why This Works

The Parity Strategy

The key insight is parity -- whether a count is odd or even. Before the game begins, all 10 people agree on this strategy:

The Rule: The person at the back counts all the black hats they can see. If the count is odd, they say "Black". If even, they say "White". This encodes the parity of all visible black hats into a single word.

How Each Subsequent Person Deduces Their Hat

  • Everyone hears every guess and knows the strategy.
  • Person 2 (second from back) knows the announced parity. They can see 8 hats ahead of them.
  • They count the black hats they see. If the parity of what they see matches the announced parity, their own hat must be white (adding their hat doesn't change parity).
  • If the parity differs, their own hat must be black (their hat flips the parity).
  • Each person after that updates the running parity based on whether the previous guess was "Black" (flip parity) or "White" (keep parity), then applies the same logic.

The Math

Let P = parity announced by the back person (0 = even, 1 = odd).

For person i, let H(i) = number of "Black" guesses heard so far (from people behind, not including the back person's actual hat), and S(i) = number of black hats they see ahead.

Their hat is Black if: (P + H(i) + S(i)) mod 2 = 1

Their hat is White if: (P + H(i) + S(i)) mod 2 = 0

Result: The first person (back of line) has a 50/50 chance -- they are the sacrifice. Everyone else can deduce their hat with 100% certainty. Guaranteed minimum: 9 out of 10 survive.

Why Does the Back Person Risk Themselves?

The back person's guess encodes information (the parity) rather than a true guess about their own hat. Their actual hat color is independent of what they see, so they have no information about it. By sacrificing their certainty, they give everyone else the one piece of missing information needed.