1. Joined
    26 Apr '03
    Moves
    26771
    17 Oct '09 17:42
    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!)
  2. Joined
    26 Apr '03
    Moves
    26771
    17 Oct '09 19:48
    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.
  3. Joined
    26 Apr '03
    Moves
    26771
    21 Oct '09 21:06
    Would anyone like me to post up my perl script for the 2^32 lockers problem?
  4. Standard memberPalynka
    Upward Spiral
    Halfway
    Joined
    02 Aug '04
    Moves
    8702
    22 Oct '09 08:27
    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.
  5. Joined
    26 Apr '03
    Moves
    26771
    23 Oct '09 03:17
    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?
  6. Joined
    15 Feb '07
    Moves
    667
    23 Oct '09 23:08
    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.
  7. Joined
    26 Apr '03
    Moves
    26771
    24 Oct '09 09:08
    Originally posted by geepamoogle
    That problem, ironically, is far easier to solve. 1,048,576 lockers would be left open.
    Correct, nice one!
  8. San Francisco, CA US
    Joined
    09 Jan '07
    Moves
    182503
    28 Oct '09 22:42
    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.
  9. Standard memberPalynka
    Upward Spiral
    Halfway
    Joined
    02 Aug '04
    Moves
    8702
    29 Oct '09 11:12
    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.
  10. Account suspended
    Joined
    28 Mar '07
    Moves
    5104
    08 Nov '09 22:59
    why would any teacher do that?
  11. Joined
    20 Oct '09
    Moves
    279
    08 Dec '09 03:41
    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.
Back to Top

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