Ad
  • Custom User Avatar

    same, but mine solution includes default case

  • Custom User Avatar

    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.

  • Custom User Avatar

    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?

  • Custom User Avatar

    @GiacomoSorbi .. please check the above issue raised by Voile concrning JS and Rubly random test cases ,, thanks in advance .. regards .. Zizou

  • Custom User Avatar

    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 ;-)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    No, that's still the same object. Look for built-in array methods to get a copy of an array ;-)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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 ;-)

  • Custom User Avatar

    Could you explain what you mean by mutating my input? I appologize in advance, I just don't understand what you mean.

  • Custom User Avatar

    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 ;-)

  • Custom User Avatar

    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 ;-)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Same. Mine says (0,0) expected but my code is returning the correct values. Are the random test wrong or am I wrong?