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.
same, but mine solution includes default case
If it's considered bad to write code that mutates input object, then it's also bad to write code that relies on user code not mutating input object. Lack of defensive coding, and can easily be exploited to disable random tests.
Also, yes, C++ version needs to be corrected as well.
Who does not need to train more? Btw, I already argued about this with B4B or somebody else - I don't give a shit if somebody modifies arrays and then gets the random tests not to work; cheating with a cleverl solution to finish a 7kyu kata? Even better than passing it as meant, if you ask me.
I will implement the fixes in this case, but I still disagree.
P.S.: you can modify the vector in c++ too, as it is not passed as a
const &
- is that fine?@GiacomoSorbi .. please check the above issue raised by Voile concrning JS and Rubly random test cases ,, thanks in advance .. regards .. Zizou
Deep clone is simple: what if some elements in your array are objects? Obviously you should copy them too, or else if you make changes to this objects, it'll be reflected on the one in the other array too.
And what if some elements of that object is, again, objects? The rabbit hole is deep here, and you need deep clone to clone all of them ;-)
This comment is hidden because it contains spoiler information about the solution
No, that's still the same object. Look for built-in array methods to get a copy of an array ;-)
This comment is hidden because it contains spoiler information about the solution
You made changes to the input array. Because it's an object the changes will persist even outside your function ;-)
The simplest fix at your end is to copy the array (deep copy, but for this kata just a shallow copy is enough). It's both discouraged for writing code that mutates the input, and writing code that'll break if input is mutated ;-)
Could you explain what you mean by mutating my input? I appologize in advance, I just don't understand what you mean.
JS and Ruby: Random tests are vulnerable to input modifications.
@GiacomoSorbi Why many of your JS translations recently have suffered the same problem? Also your kata translations are pretty iffy these days, maybe you need to train more ;-)
Looks like mutating the input is causing problems again.
I'll resolve this issue since it's not clear about the actual issue, and re-raise a clear one. Meanwhile, don't mutate the input ;-)
This comment is hidden because it contains spoiler information about the solution
Same. Mine says (0,0) expected but my code is returning the correct values. Are the random test wrong or am I wrong?