/Prisoners-and-Warden

Prisoners and Warden problem

Primary LanguagePython

Prisoners-and-Warden

Prisoners and Warden problem

N prisoners sit in the main cell together. Evilous warden decides to paly a rough game on them. Effective next night the warden would draw a random prisoner and place him in an isolated chamber. The game goes on until a next prisoner surely states that all of the prisoners have been to the isolated cell. If that matches the reality, then the game is over and everyone is happy. Otherwise the evilous warden butchers all of the prisoners and they all die. The prisoners surely want to live, who doesn't...

While the game has not started the prisoners can come up with a plan, agree on something that would allow them to survive. Once the game is started no further communication b/w the prisoners are no longer possible.

The isolated cell where the evilous warden brings in a random prisoner every night has a lantern. The lantern can either be ON or OFF. It is up to an isolated prisoner what to do with the it while he's in there.

What should the poor prisoners agree upon that my allow them to exit the game and remain alive?