Ad
  • Default User Avatar

    What happens if you drop the stack from your solution? Does it work the same without it?

    Looking at your code, I'd say ")(" is probably the simplest case that will make it fail.
    Print out important variables to see what your code does.

  • Custom User Avatar

    Whatever the two tests (failing) are expecting is what my code is giving as outputs.

    You got this part wrong. Sample tests are OK, and your solution has an error and returns wrong results.

    Run your solution locally, in your IDE, for example with parameter "" (i.e. empty string). Sample tests expect it to return True. Check locally what it returns. It will probably make easier for you to find your mistake.

  • Custom User Avatar

    But that's what I am saying. Please check the sample tests. Whatever the two tests (failing) are expecting is what my code is giving as outputs. The error thrown says the opposite.

  • Custom User Avatar

    Not an issue. Your solution doesn't even pass the "" sample test. And use spoiler tags.

  • Custom User Avatar

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

  • Default User Avatar

    Mutating the input is changing the parameter in a function. For instance:

    a = [1, 2, 3, 4]
    def sumlist(x):
      total = 0
      while len(x) > 0:
        total += x[0]
        x.remove(x[0])
      return total
    res = sumlist(a)
    print(a)# will print []
    #list a is modified, which is bad most of the time.
    
  • Custom User Avatar

    Thanks for that.
    A quick one before you go. I am still getting my hands dirty with all this. Could you send a resource on this input mutation. I am not sure I understand what is meant and could not find any resource that quite explained it well. I came across it in another kata I was doing and didn't finish it as it was the only test failing.
    Thanks.

  • Custom User Avatar

    Don't mutate the inputs. Never. Unless you're told you can explicitely.
    But so, it was an issue.

    edit: corrected

  • Custom User Avatar

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

  • Custom User Avatar

    Not an issue. Print the inputs.

  • Custom User Avatar

    My implementation in Python fails one of the basic tests yet outputs exactly what is expected from the failing test. Any assistance?