Home > Riddles > The executioner and the hats (3 colors)

The executioner and the hats (3 colors)

Numerical territoryLevel 5 · Expert · ●●●●●

There are 10 people in a row, numbered from 1 (front) to 10 (behind).
Each hat can be red, blue or green.
Vision and turn rules:

  • person 10 speaks first and sees the hats of 1..9,
  • person 9 speaks next and sees 1..8,

-...

  • person 1 speaks last and sees none.

Everyone hears the previous answers.
Before starting you can agree on a strategy.
How many people can be guaranteed to be saved with certainty?

Hints

Show hints
  1. All except the first are determined uniquely.
  2. Person 9 knows $y_{10}$, sees $x_1,\dots,x_8$, and solves for $x_9$: $x_9\equiv-\big(y_{10}+x_1+\cdots+x_8\big)\pmod{3}$. He says it and he gets it right.
  3. Coding: red=0, blue=1, green=2 (module 3).

Solution

Show full solution

Back to problem
Answer: 9 saved are guaranteed.
Coding: red=0, blue=1, green=2 (module 3).
Let $x_1,\dots,x_{10}$ be the real value of each hat.
Person 10 (first to speak), who sees $x_1,\dots,x_9$, says:

$$ y_{10}\equiv-(x_1+\cdots+x_9)\pmod 3. $$

It may fail, but it leaves the equation fixed:

$$ y_{10}+x_1+\cdots+x_9\equiv0\pmod3. $$

Person 9 knows $y_{10}$, sees $x_1,\dots,x_8$ and solves $x_9$:

$$ x_9\equiv-\big(y_{10}+x_1+\cdots+x_8\big)\pmod3. $$

He says it and he gets it right.
Then person 8 already knows $x_9$ (heard), sees $x_1,\dots,x_7$ and solves for $x_8$; and so on until 1.
All except the first are determined uniquely.
Guarantee: 9 saved always; The first one only has a probability of $1/3$ of being correct.


Related riddles

Keep practicing

If you enjoyed this one, try more pure-logic riddles, explore this theme, browse the full archive, or read the riddle-solving guide.

← Previous: The scales of Babel · Next: The cursed chocolate (Chomp) →