Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
No random tests in JavaScript (at least).
As your code mutates the input list (as I already said), the reference function gets that as input and returns wrong expected results.
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 ....
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.This comment is hidden because it contains spoiler information about the solution
Please do, use markdown formatting and mark your post as having spoiler content.
The user can mutate the input in Python.
those are my results, it failed cause it expect something else
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 ;-)
I've tried the reference solution and I got these results for the input you mentioned:
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?
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
Are you mutating the input list?
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
I've tested in repl.it and failed too for the reason I told.
As I said that is a valid PHP code ... ;-)
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...