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.
Took me long enough, but it's fixed now, please verify.
thanks a lot, approved
This comment is hidden because it contains spoiler information about the solution
Thanks!
Hey, an interesting scenario, but this should be treated the same way as any other. Let's say we have an array
[-5, 10, 8, 10, 2, -3, 10]
; as you can see there are 3 occurences of10
, but still the algorithm works the same way: the greatest is10
, so it goes in the middle, the next greatest is10
, so it goes on both sides, then10
again on both sides, and after that the other numbers accordingly, resulting in[-5, -3, 2, 8, 10, 10, 10, 10, 10, 8, 2, -3, -5]
. I added this to the tests for clarity nevertheless.You're right, I ommited this in the sample tests. Already fixed that, but since sample tests are editable it's not that big of an issue.
No, the kata test cases all provide a list with exactly one duplicated element, so both
start
andend
will have actual numerical values; to be specific - index of the first occurence of the duplicated element and the index of the second occurence of the same element. These are then used to return the expected slice of the input list.in case of that kata, the right side of the first assignment will always return a list with two values (the input list will only have one duplicated element, so the condition
arr.count(x) > 1
will be met only for two identical elements), thus the assignmentstart, end = [...]
will assign a first value tostart
and second toend
. The values are indices of this elements, beacuse as you can see I am using theenumerate
function (for more info check the Python docs onenumerate
) on the input array.Check the sample test cases to see what is wrong. Specifically, the first test case.
Definitely,
692
was duplicated in the input list, and also the median, so it should a middle element in the output, as well as reflected on both sides of the middle element, just like Chrono79 stated.Great, now I can work with this :D Your code is fine except for one important detail you oversaw. Think about how you remove the processed
arr
elements and visualize your algorithm on this example:[-3, 15, 8, -1, 7, -1]
^^ I think you will get this in no time. edit: let me know if you figured this out, I really want you to get something out of this kata!The description was updated after adressing this suggestion to "Your function should not mutate the input array, and this will be tested". Your solution clearly mutates the input.
Again, the error message you provided is far to vague, I don't know what's wrong. Post your code (with spoiler flag), so we can look into this.
Approved, thanks.
Meh, you probably need to fork this again, because I cannot approve this automatically, there's an annoying bug on CW.
Loading more items...