The Locker Puzzle
This is my favorite puzzle.
A hallway in a school has 100 lockers. A student runs down the hall and opens every locker. A second student runs down the hall and closes every other locker, starting at the second. A third student runs down the hall and "flips" every third locker, starting at the third - if the locker is open, he closes it; if it's closed, he opens it.
A total of 100 students run down the hall, opening and closing lockers. In general, the n-th student flips every n-th locker.
After all 100 students run through the hall, which lockers are open?
A hallway in a school has 100 lockers. A student runs down the hall and opens every locker. A second student runs down the hall and closes every other locker, starting at the second. A third student runs down the hall and "flips" every third locker, starting at the third - if the locker is open, he closes it; if it's closed, he opens it.
A total of 100 students run down the hall, opening and closing lockers. In general, the n-th student flips every n-th locker.
After all 100 students run through the hall, which lockers are open?

21 Comments:
There are (at least) two ways of solving this: brute force, where you imitate the students on paper or by flipping coins, etc, and logically. Extra points for solving it logically.
Also: that guess you have in your head? The one that seems to make sense and now you just have to prove it? It's wrong.
i'm going to go with brute force
but i'm not going to use paper or coins. i'm going to use lockers and students.
What about simplification (which is neither brute force nor logic)? I imagined 4 kids and 4 lockers.
i don't have a favorite puzzle.
This post has been removed by the author.
This post has been removed by the author.
Frank, how did you simplify to four without subsequently using brute force or logic?
Also it's only really solved if, once you've solved for 4, you can predict the other ones up to 100 or further.
as far as i can tell, frank hasn't accomplished anything yet. all right, i'm going to sneak into a junior high school right now and break this thing wide open.
John, a high school hallway or a college gymnasium would work just as well.
Where's Bernie in all this; Bernie with her precious primes?
interesting that you mention primes. here's what i've got so far. all primes end up closed, since they start open and will only be closed the one time someone passes through. numbers with even numbers of factors end up closed. odd number of factors is open. i don't know how to take this any further with an n and also maybe an nth and other symbols. but i am closing in on a pattern for the value of pi. i should have it soon. i'll be back in a little bit.
a cursory one-coffee thought in the a.m. leads me away from precious primes, and makes me think perfect squares are the lockers left. clarification anon!
i think bernie's right. but, in my defense, it seems only perfect squares have an odd number of factors, since, otherwise, factors come in pairs.
How can robert know the guess in my head is wrong?
Yes, it's the perfect squares. Full points to Bernie for figuring it out; full points to John for mentioning the odd number of factors, but with a few points subtracted for bringing pi into it.
Bernie wrote:
How can robert know the guess in my head is wrong?
Because everyone who knows math at all starts out by thinking it's the prime numbers!
Robert, I found your taunt about primes to be a red herring, and I consequently wasted about six or seven minutes thinking about primes, then realized, this isn't about primes!
You would have gone to primes anyway. Trust me.
In my haste to come up with a solving strategy that was neither brute force nor logic, I misread the puzzle.
No way on going to primes. I have a prime number bell it my head. It certainly didn't go off upon reading this.
Bernie, I would like to believe you.
Post a Comment
<< Home