One helper who may swap two slips
The setup is the classic one: 100 prisoners, 100 boxes with the prisoners' numbers inside in random order, each prisoner may open 50 boxes, and they use the follow-the-chain strategy. Everyone goes free only if all 100 succeed.
A sympathetic guard is allowed, before the first prisoner enters, to open every box, look at every slip, and swap the contents of exactly two boxes (or leave everything as it is). He knows the prisoners' strategy but cannot talk to them.
Can the guard guarantee that all 100 prisoners succeed? If so, what should he do?
Show a hint
The chain strategy fails exactly when the arrangement contains a cycle longer than 50. There can be at most one such cycle. What does swapping two slips do to a cycle?
Your answer
Solving needs a free account
Answers, streaks and solutions unlock when you are signed in. Reading the question and the hint stays free.
Discussion
💡 Discussion rules
- No full solutions here. Hints and approaches only.
- Complexity, edge cases and intuition are the point.
- Interview experiences are welcome. Respect your NDAs.
Loading discussion…
Learn the concepts
The theory behind this question.