Talk:100 doors

From Rosetta Code
Revision as of 22:20, 11 October 2007 by rosettacode>Drea

An observation: You're actually making 101 passes. 100 mutative, and one for reading the final state. I'm wondering if the wording of the task should be changed, as no way of reporting the final state within the first 100 passes immediately comes to mind. --Short Circuit 00:14, 7 October 2007 (MDT)


Oddly enough it seems that the only doors left open after all the passes are complete are those which are perfect squares of integers: 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100 Triviallly trying the same code for 1000 doors and 1000 mutative passes seems to suggest that this is true for larger numbers (though its far from proven). I should, undoubtely, do a proper analysis to see if I can prove that it generalizes and explain why.JimD 16:03, 11 October 2007 (MDT)

The number of times a door is visited is the same as the number of factors of the door's index. Open doors have been visited an odd number of times and only perfect squares have an odd number of factors. This [1] explains it.Drea 16:20, 11 October 2007 (MDT)