Go back
math problem

math problem

Posers and Puzzles

iamatiger

Joined
26 Apr 03
Moves
26771
Clock
17 Oct 09
Vote Up
Vote Down

Originally posted by geepamoogle
Hmm, it occurs to me to find the LCM and figure out what portion of those are open and closed. Then figure out how many are left after all the complete runs are done.

Unfortunately, this runs into a little problem in that you have 4,294,967,301 lockers, and an LCM of 5,354,228,880.

However, if you could determine the first 22 boys (LCM=232,792,560 ...[text shortened]... very 23rd locker, it may be more easily solved with a mere 186,737,708 checks for the final run.
Answer available now, so if anyone else gets an answer I'll tell you if you are right. My program took 41 hours to do it! (mucho respect if you can compute the answer quickly!)

iamatiger

Joined
26 Apr 03
Moves
26771
Clock
17 Oct 09
Vote Up
Vote Down

Originally posted by geepamoogle
Hmm, it occurs to me to find the LCM and figure out what portion of those are open and closed. Then figure out how many are left after all the complete runs are done.

Unfortunately, this runs into a little problem in that you have 4,294,967,301 lockers, and an LCM of 5,354,228,880.

However, if you could determine the first 22 boys (LCM=232,792,560 ...[text shortened]... very 23rd locker, it may be more easily solved with a mere 186,737,708 checks for the final run.
Implementations of programs to solve this need to be a little careful about storing very large arrays. For instance, if a program needs an array of 2^32 booleans (door open / door closed), even if they are packed into 1 bit each (which might hit execution speed), that single array will need about half a gigabyte of RAM.

iamatiger

Joined
26 Apr 03
Moves
26771
Clock
21 Oct 09
Vote Up
Vote Down

Would anyone like me to post up my perl script for the 2^32 lockers problem?

P
Upward Spiral

Halfway

Joined
02 Aug 04
Moves
8702
Clock
22 Oct 09
Vote Up
Vote Down

Originally posted by iamatiger
Would anyone like me to post up my perl script for the 2^32 lockers problem?
So the iamtiger coder defeated the iamtiger code-defeater. Yin and yang.

iamatiger

Joined
26 Apr 03
Moves
26771
Clock
23 Oct 09
Vote Up
Vote Down

Originally posted by Palynka
So the iamtiger coder defeated the iamtiger code-defeater. Yin and yang.
Yes, sorry about that!

Can anyone solve the following altered problem, which would defeat my code!
'
There are 2^40 pupils in the school, and 2^40 lockers
In turn, each pupil walks down the row of lockers. the first one opening every locker. the second one changing the state of every second locker, the third one changing every third and so on.

How many lockers are open when the exercise completes?

g

Joined
15 Feb 07
Moves
667
Clock
23 Oct 09
Vote Up
Vote Down

Originally posted by iamatiger
Yes, sorry about that!

Can anyone solve the following altered problem, which would defeat my code!
'
There are 2^40 pupils in the school, and 2^40 lockers
In turn, [b]each
pupil walks down the row of lockers. the first one opening every locker. the second one changing the state of every second locker, the third one changing every third and so on.

How many lockers are open when the exercise completes?[/b]
That problem, ironically, is far easier to solve. 1,048,576 lockers would be left open.

iamatiger

Joined
26 Apr 03
Moves
26771
Clock
24 Oct 09
Vote Up
Vote Down

Originally posted by geepamoogle
That problem, ironically, is far easier to solve. 1,048,576 lockers would be left open.
Correct, nice one!

ParShooter

San Francisco, CA US

Joined
09 Jan 07
Moves
188923
Clock
28 Oct 09
Vote Up
Vote Down

Originally posted by wormer
In a school there are 1000 lockers. The principle of this school takes 4 students. He tells the first one to open every locker, the second one to close every second locker, the third one to open or close every third locker finally the forth one to open or close every forth locker. After these round ups how many lockers will be open?
600!

I did it manually for 10 lockers and got 6 open, 4 closed. I multiplied 6 * 100 = 600.

P
Upward Spiral

Halfway

Joined
02 Aug 04
Moves
8702
Clock
29 Oct 09
Vote Up
Vote Down

Originally posted by ParShooter
600!

I did it manually for 10 lockers and got 6 open, 4 closed. I multiplied 6 * 100 = 600.
That's not a bad approximation, but since you know that the LCM of 2,3 and 4 is 12 then you only needed to to it manually for 2 more to get a precise solution.

E

Joined
28 Mar 07
Moves
5104
Clock
08 Nov 09
Vote Up
Vote Down

why would any teacher do that?

b

Joined
20 Oct 09
Moves
279
Clock
08 Dec 09
Vote Up
Vote Down

I just had this math problem in my math class today with just 25 lockers. The answer was 1,4,9,16, and 25. I think it's all the number's with whole numbers as their square roots.

Cookies help us deliver our Services. By using our Services or clicking I agree, you agree to our use of cookies. Learn More.