Originally posted by geepamoogleAnswer 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!)
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.
Originally posted by geepamoogleImplementations 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.
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.
Originally posted by PalynkaYes, sorry about that!
So the iamtiger coder defeated the iamtiger code-defeater. Yin and yang.
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?
Originally posted by iamatigerThat problem, ironically, is far easier to solve. 1,048,576 lockers would be left open.
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]
Originally posted by wormer600!
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?
I did it manually for 10 lockers and got 6 open, 4 closed. I multiplied 6 * 100 = 600.