Skip to main content

Timeline for "Open and closed doors" riddle

Current License: CC BY-SA 3.0

14 events
when toggle format what by license comment
Sep 5, 2014 at 9:42 vote accept Anirudh
Aug 28, 2014 at 14:15 history edited Pimgd CC BY-SA 3.0
MATHJAAAX
Aug 28, 2014 at 14:11 comment added Anirudh Yeap! I think you are right. I probably made a mistake while evaluating Iterations :-]
Aug 28, 2014 at 14:07 comment added Pimgd @Anirudh \$O(n!)\$? I disagree... you had \$O(n^2)\$ with extra reductions. N = 10 for instance, you'd have 10 + (10/2 = 5) + (10/3 = 3) + (10/4 = 2) + (10/5 = 2) + (10/6 = 1) + 1 + 1 + 1 + 1 = 27, not 3.8 million.
Aug 28, 2014 at 14:04 comment added Anirudh @Pimgd Well you have simplified this pure on the basis of optimizing the Algorithm which works better Space and Memory complexity wise with \$O(n)\$ Time complexity and \$O(1)\$ Space Complexity. As compared to my Time Complexity \$O(n!)\$ and Space \$O(n)\$
Aug 28, 2014 at 13:02 history edited Pimgd CC BY-SA 3.0
final parameteeer
Aug 28, 2014 at 12:11 history edited Pimgd CC BY-SA 3.0
explanation of changes
Aug 28, 2014 at 11:43 history edited Pimgd CC BY-SA 3.0
better explanations
Aug 28, 2014 at 11:18 comment added rolfl The instructsion say: "find all the doors that will remain open after N passes.", just sayin... ;-) But your code is more compatible with the OP's code.
Aug 28, 2014 at 11:17 comment added Pimgd @rolfl I gotta print the closed ones too
Aug 28, 2014 at 11:16 comment added rolfl You could simplify the logic (and make it even faster), by using for (i = 1; i <= (int)Math.sqrt(passes); i++) {...print("The door number " + (i * i) + " is Open);}
Aug 28, 2014 at 11:06 history edited Pimgd CC BY-SA 3.0
added 128 characters in body
Aug 28, 2014 at 10:58 history edited Simon Forsberg CC BY-SA 3.0
Aligned the doors
Aug 28, 2014 at 10:54 history answered Pimgd CC BY-SA 3.0