All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
The last locker (Posted on 2008-12-20) Difficulty: 2 of 5
There is a line of lockers numbered 1 to 1024, initially all closed.

A man walks down the line, opens 1, then alternately skips and opens each closed locker (so he opens 1, 3, 5, ... , 1023). At the end of the line he walks back, opens the first closed locker, then alternately skips and opens each closed locker (so he opens 1024, skips 1022 and so on).

He continues to walk up and down the line until all the lockers are open.

Which locker is opened last?

See The Solution Submitted by pcbouhid    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
analytical solution | Comment 1 of 4

after the first pass we are left with only even number still closed so the number of the lockers still closed can be given by 2t with t>=0 and t<=512.  Now the next pass he alternates opening and closing these lockers starting at 1024, so now the lockers left open is given by 1022-4t with t in [0,255].  Now we can notice a pattern that at each step the number of the lockers left closed is in arithmetic progression and the common difference is double the previous one.  So the following table lists the progression in t for each step and the range for t

2t  [0,512]
1022-4t  [0,255]
6+8t  [0,127]
1014-16t [0,63]
22+32t  [0,31]
982-64t  [0,15]
86+128t  [0,7]
854-256t [0,3]
342+512t [0,1]
342

and thus the last locker to be closed is 342


  Posted by Daniel on 2008-12-20 22:40:55
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (21)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information