Updated June 5, 2012. (Scroll to the end for the update.)

This week’s Numberplay is about a locker room full of, well, lockers – 100 of them, to be exact. The lockers are closed until a janitor (let’s call her Portia) visits the room and opens them all. Then Portia visits the room again and closes every other locker. Later on, she visits the room a third time, opening or closing every third one. And so on, for 100 visits in all.

Head over to the Times, then come back here and enjoy the pictures.

Picture #1. The 100 lockers of the puzzle are represented as a row of tiny squares – red squares for closed doors, green for open. The squares in the top row (all green) show the lockers all open after Portia’s first visit to the locker room.

The second row of squares, alternating green and red, show the lockers after her second visit, and so on.


If you squint at the patterns across the top, I think you can see Portia’s face.

Picture #2. After Portia’s first visit to the locker room, all 100 lockers are open. After her second visit, 50 are open and 50 are closed. Ninety-eight visits later, ten lockers are open. (Just which of the lockers are open in the end is the beautiful result of the puzzle, which you’ll find more easily in the comments to this week’s puzzle than you will by trying to count the tiny squares in the picture here.)

You might wonder – I did anyway – how the number of open lockers changes between Portia’s second and hundredth visit. Here’s a graph.


What a delightfully curious graph! The number of open lockers wanders seemingly aimlessly about the low 50s for a while. It briefly threatens to stay put at 54, then glides down with a few small bumps to a final value of 10.

Intrepid readers can find the Excel spreadsheet I created these pictures from here.

Thanks to Gary Antonick for sharing this great puzzle, which was suggested by Volodymyr Ivanchenko.

Updated June 5, 2012. Back at Numberplay, Gary suggested looking for the number of open lockers sequence at the Online Encyclopedia of Integer Sequences. I didn’t find anything, and I suspect that’s because this puzzle gives different sequences for each initial number of lockers.

So, I put together a SQL Server 2012 script (and posted it at SQL Fiddle here) to generate data for this “number of open lockers” graph for locker rooms with other than 100 lockers.

The graph gets even more interesting when there are more lockers.