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.
//
When do you find the repetition?
Testing for -3 10 9 -7 -3 9 10 -7 -8 -8 9 1 10 2 -3
It should work for random inputs too: [-3, 10, 9, -7, -8] should equal [-3, 9, 10, -7, -8]
But what's wrong with this output?
The first number that repeats is -3, then -10 then 9 and so on.
No, read the instructions again, about the first test:
$this->assertEquals(3, count(duplicates([1, 2, 4, 4, 3, 3, 1, 5, 3, '5'])));
The first number that repeats, parsing from the left is 4, then 3 and lastly 1, so the expected answer is
[4, 3, 1]
it has nothing to do with descending order.I have no idea when/why that happened... Thanks for fixing :D
Restored previous description.
@A.Partridge why did you change it in the first place?
Thanks :) I think it counts as a one-liner solution
Recommended why? Was there a specific function that offers a better/different solution? If so, happy to hear it.
SPOILER FLAG, DAMN YOU! X(
it's not as if I already told you twice!
spoiler flag, bis
spoiler flag...
This comment is hidden because it contains spoiler information about the solution