Ad
  • Custom User Avatar

    You can save the whole iteration of the map function by doing the calculation in each iteration of the reduce function

  • Custom User Avatar

    Well, there are 600+ valid solutions for Python, so I don't think the tests are wrong. There are some edge cases that are not properly tested, so if anything, they are easier to pass than they should be.

    Are you sure you take into account that the number of characters don't always add up? is_merge('a', 'a', 'a') should be False for example, just like is_merge('abc', 'a', 'b').

    If you still are convinced that your code is correct, please let me see it and I'll see what I can do.

  • Custom User Avatar

    Sorry for taking my time. I have a busy time at work, currently.

    Well, this code does not work. I haven't done very much python, but your reasoning in the code above is easy to follow.

    Your problem is the line if s[-1] and string[index] in normpair or curlypair or squarepair:. It does not do what you intend it to.

    I think you mean if (s[-1] + string[index]) in [normpair, curlypair, squarepair]:.

    Even so, you don't take into account that there may be extra left braces. For example, you return True for '('. You need to check that s is empty in the end.

    Other than that your code works fine for me. (Assuming that you got your indentation correct.)

    Let me know if can still help you with this kata.

    I will remove the issue tag from this question. If you still think there is an issue with this kata, please give me some code that you don't think is working and I'll see what I can do.

    Good luck! :-)

  • Custom User Avatar

    Currently Codewars platform is experiencing issues.

  • Default User Avatar

    I passed all tests but I'm unable to submit... not sure if this is a problem on my end.