Ad
  • Default User Avatar

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

  • Custom User Avatar
    lst = [1, 2, 3]
    lst.pop(0)
    print(lst) #[2, 3]
    

    As your code mutates the input list (as I already said), the reference function gets that as input and returns wrong expected results.

  • Custom User Avatar

    arr.pop(0) mutates the list. Try using a copy. And I'll close this issue, because FArekkusu created another one about the input being mutable in Python.

  • Custom User Avatar

    Please do, use markdown formatting and mark your post as having spoiler content.

  • Custom User Avatar

    I've tried the reference solution and I got these results for the input you mentioned:

    {'pos': [1, 5, 8, 12, 15, 18], 'peaks': [18, 20, 13, 11, 14, 17]}
    {'pos': [2, 7, 9, 12, 14, 16], 'peaks': [8, 13, 12, 15, 13, 12]}
    {'pos': [4, 6, 9, 12, 15, 18, 20, 22, 26, 28], 'peaks': [18, 8, 12, 5, 19, 12, 7, 18, 15, 20]}
    

    Actual and expected order is ok in the tests, so we can discard that as a problem.
    Could you print the input before you return so you can be really sure the list was not mutated?

  • Custom User Avatar

    Are you mutating the input list?

  • Custom User Avatar

    I've tested in repl.it and failed too for the reason I told.

  • Custom User Avatar

    Not a kata issue, either remove it from the if or add parentheses so the assignment is done before the comparison, right now it's doing the comparison first and assigning that to $pos.
    Read about operators precedence