Ad
  • Custom User Avatar

    No random tests in JavaScript (at least).

  • 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

    Sorry, I dont get you, I only loop the list and I have my own position reference, you can see all my output are right ....

  • 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

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

  • Custom User Avatar

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

  • Custom User Avatar

    The user can mutate the input in Python.

  • Custom User Avatar

    those are my results, it failed cause it expect something else

    {'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]}
    

    in the description check the ouutput says should equal ....

    I can post my answer code in case you want to verify I'm not altering the input ;-)

  • 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

    No, I'm looping the array as it is. I think it has to do with the negative values, always failed when they are negatives values involved

  • Custom User Avatar

    Are you mutating the input list?

  • Custom User Avatar

    I got invalid test for the following case:
    pick_peaks([7, 18, 16, 18, 18, 20, -4, 11, 13, 4, 8, 10, 11, 2, -3, 14, 4, 8, 17, 7, 0, 8, 10]
    my answer: {'pos': [1, 5, 8, 12, 15, 18], 'peaks': [18, 20, 13, 11, 14, 17]}
    the program expected: {'pos': [3, 6, 10, 13, 16], 'peaks': [20, 13, 11, 14, 17]}
    regarding the description first peak is in the pos 1 (number 18), dont understand why I'm getting wrong answer

    Y try more attempts same errors:

    Testing for [16, -4, 8, 6, 0, 0, 10, 13, 1, 12, 0, -4, 15, 11, 13, 10, 12, 12, -1, 19]
    {'pos': [2, 7, 9, 12, 14, 16], 'peaks': [8, 13, 12, 15, 13, 12]}
    should equal
    {'pos': [5, 7, 10, 12, 14], 'peaks': [13, 12, 15, 13, 12]}

    Testing for [8, 6, 6, 7, 18, -3, 8, 1, 11, 12, 2, -1, 5, -1, 11, 19, 13, 4, 12, -3, 7, 4, 18, 18, 12, 2, 15, 8, 20, 8]
    {'pos': [4, 6, 9, 12, 15, 18, 20, 22, 26, 28], 'peaks': [18, 8, 12, 5, 19, 12, 7, 18, 15, 20]}
    should equal
    {'pos': [2, 4, 7, 10, 13, 16, 18, 20, 24, 26], 'peaks': [18, 8, 12, 5, 19, 12, 7, 18, 15, 20]}

    Can someone please clarify, thanks

  • Custom User Avatar

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

  • Custom User Avatar

    As I said that is a valid PHP code ... ;-)

  • 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

  • Loading more items...