Ad
  • Custom User Avatar

    So in the description, when you write:

    "The equation could be stated as follows:

    Johnny runs down the row of lockers n times, starting at the first locker each run and skipping i lockers as he runs, where n is the number of lockers there are in total and i is the current run."

    you actually mean:

    " ... starting at the ith locker each run and skipping i lockers as he runs ... "

    You really need to change the description. Perhaps you mean "start skipping locker numbers" at the first locker, but most native english speakers would interpret your words as "start flipping lockers" at the first locker. Also, you need to specify that all the lockers start out closed!

  • Custom User Avatar

    Because there is an edge condition that loops forever on your first while loop.

    (I don't know why your Sublime isn't looping forever on this.)

  • Custom User Avatar

    I reread it, and I suppose that you did say "n lockers and n runs" but you did that inside the text box.

    When you described how many times he runs by, and what he does when he runs by, you get to 3 and then stop. That description makes me (as well as others, obviously) think that he only runs three times.

    Maybe just add something that explaings outside of the text box that states that he runs once for each locker there is.

  • Custom User Avatar

    Why is locker 3 being affected at the second run? It goes:

    First run
    1-2-3-4-5...
    Second run
    2-4-6-8-10...
    Third run
    3-6-9...

  • Custom User Avatar

    total lockers : 5
    open after second run : [1, 3, 5]
    lockers affected by second run : [3]
    returned [1, 5] should equal [1, 4]

    How is it possible that 4 should be open but 5 should be closed?
    Am I missing something?

  • Custom User Avatar

    Never mind, I got the question wrong. Resolved it.

    Note that the question is asking for removal of the longest PREFIX, so any sub-array that satisfy but is not prefix should not be removed.

  • Custom User Avatar

    I've tried many times but still having 2 tests failed:

    the dropWhile function
    should be defined
    Test Passed: Value == []
    should work when testing for even numbers
    Test Passed: Value == []
    Test Passed: Value == [1,5,4,3]
    Expected: [1,4,2,3,5,4,5,6,7], instead got: [1,3,5,4,5,6,7]
    Test Passed: Value == [5,3,4,6]
    Test Passed: Value == [1,1,1]
    should work when testing for odd numbers
    Test Passed: Value == []
    Expected: [2,1,2,4,3,5,4,6,7,8,9,0], instead got: [2,1,2,4,4,6,7,8,9,0]
    Test Passed: Value == [2,4,6,4,5]
    Test Passed: Value == [86,902,2,1]

    I didn't modify the original array btw. Anyone got same problem ?

    Besides, if two sequences satisfy the predicate and have same length, which one should be removed ?

  • Custom User Avatar

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