Ad
  • Custom User Avatar
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Yeah, that lockers array will get too large.
    As I said, just do the problem by hand for a bunch of examples.

    If you need an additional tip, think about the numbers which have odd number of divisors.
    (Usually, numbers have an even number of divisors as for every i, there is n/i).

  • Custom User Avatar

    By a for in a for, do you mean a nested loop?
    Am I correct in assuming you are simulating the entire process?

    Try a few examples by hand, and look at the numbers on the lockers which are left open.
    The pattern is impossible to miss.

  • Custom User Avatar

    It's most likely your program. Do you make an array of numbers upto the given number?
    Because it goes upto 1e9. Your program might use too much memory if you do that.

  • Custom User Avatar

    var self = this; used to widely agreed as the best practice for performing a closure.

    bind(this) is starting to gain acceptance as IE8 is dropping off the map.

    Referencing the variables directly is largely bad design, because if a developer changed "alpha" to another variable, some IDEs may not pick up on the refactor of the nested "alpha" in an anonymous function.

  • Custom User Avatar

    Agreed. No idea what is being asked

  • Default User Avatar

    The return statements are for different functions