/pirate-island

Pirate Island Problem

Primary LanguagePython

100 pirates are on an island, each with a cross on the back of their head. Either red or blue. An executioner lines them up on a beach, paints a color on each pirates head, and tells each pirate to call the color on the back of their head, which they cannot see.

If they get the color wrong, they are shot. Otherwise, they live. Pirates cannot communicate with each other and can only say one word, either 'red' or 'blue' while on the island. Each pirate can see the head of all pirates ahead of him, but not his own, or the ones behind. How can you maximize the chances of the pirates survival?