Ad
  • Custom User Avatar

    Why would you assume that? If test cases were wrong, the kata wouldn't be approved. The problem comes from the fact that:

    1: you're mutating the input string (rarely a good idea)

    2: the tests do not guard against this. First, your function is run with the mentioned string, which you mutate, and then the reference solution is run with what's left of the string, leading to unexpected results.

    #2 is actually an issue, and should be fixed. I already see some issues raised below about it, and I'm amazed that this issue hasn't been fixed for 4 years or something?!

    Still, I have to close it as duplicate (for now). Try to avoid mutating input where possible.