Back to Interview Games

Prisoners and Hats

LogicHard
20 min
40 pts

Description

Logic signaling to save group with hat colors.

Game Rules

100 prisoners are lined up. Each can see hats of those in front. They must guess their own hat color. Devise a strategy to save as many as possible.

Examples

First prisoner counts red hats ahead

Uses parity to signal

Others decode the signal

Hints

  • Use parity (even/odd)

  • First prisoner sacrifices for others

Solution (Click to reveal)

First prisoner counts red hats ahead. If even, says 'red'; if odd, says 'blue'. Others can decode and determine their hat color. Saves 99 prisoners.

Back