Skip to content

Puzzle #18 The Long Hall

There is a hallway with 100 doors labeled 1, 2, 3, etc. up to 100 in order. At first, all of the doors are closed. By toggling a door, I mean changing its position (i.e. opening it if it is closed and closing it if it is open). You walk down the hall and toggle every door (in this case, opening them all). Then a second person walks through and toggles every 2nd door (doors 2, 4, 6, etc.) Then a third person toggles every 3rd door (3, 6, 9, etc.) This continues until the 100th person only toggles the 100th door. Which doors are open at the end?

You could, of course, solve this by brute forcing a simulation of the hallway and merely observing which doors end up open. It will be much more satisfying to think through the problem and discover the reason that a door ends up open or closed.

Find the solution at the bottom of this page.