images are no longer exist
Performance-wise this solution is not really good...
(half)moves boundary cases are not tested.
halfmoves = moves*2 (False)
halfmoves = moves*2-1, active='w' (False)
I know, but if mutation was possible no, you can't.
Ehm, Chrono .. you can work back from expected to get the input.
Correct! My mistake. Sorry for the spam. I didn't understand what "mutates the input" means, but I finally got it.
No, the kata test cases all provide a list with exactly one duplicated element, so both start and end 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.
ok so you mean that the start variable automatically takes the value of the first variable which is related to the end counter?
So if no variables allow the counter to reach greater than 1 then the value of start would have been None, right?
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 assignment start, end = [...] will assign a first value to start and second to end. The values are indices of this elements, beacuse as you can see I am using the enumerate function (for more info check the Python docs on enumerate) on the input array.
arr.count(x) > 1
start, end = [...]
They are just declaring a variable they will use to store the index of the first repeated element
can someone tell me what does the start refer to ?
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.
Oh! Two repeated numbers so both of them will be removed in the processed arr. I've changed my solution in the while loop and it worked fine now.
Thanks David for the help! Nice kata to practice on :)
Without the input value it is hard to say, it could appear twice in the input (and because one of them was the middle value, only the other one got reflected) or maybe you've mutated it. After seeing the tests, it seems you would get an error message in that case, so it seems it's the first option.