Ad
  • Custom User Avatar

    Check out the Python docs, especially the "Important warning!"

  • Custom User Avatar

    Change the last lines of your code to this:

    # ...
    # Check if new coordinates are out of bound
    def out_of_bound(x, y, size):
        return x < 0 or y < 0 or x >= size or y >= size
    
    maze = "\n".join([
            "...",
            "WWW",
            "W.." 
        ])
    print(path_finder(maze))
    
    # This test case gives different answers for me. Should return True, but it returns False in Codewars
    maze = "\n".join([
            "...",
            "W.W",
            "W.." 
        ])
    print(path_finder(maze))
    

    You can run it in https://programiz.pro/ide/python and you will see how your function returns False twice, while the second input should result in True.

  • Custom User Avatar

    It's just frustrating that Codewars seems to behave differently from other iterpreters.

    It really does not. It's problem with the tests you do in other interpreters. Your tests are incomplete.

    Codewars uses exactly the same Python as other places, you just perform your tests incorrectly. The prev = [(0,0)] part in your function introduces a subtle bug which does not manifest in other environments because your tests are incomplete. Try running your solution twice in any other place and you will notice the same problem.

    Your solution has a bug, it's not a problem with Codewars' Python.