Ad
  • Custom User Avatar

    Hello, sorry for answering so late, but I only just came back from holidays ^^'
    Your solution is not very efficient, but it should actually be enough. What's preventing you from solving the puzzle are these three lines:

    if not coordi(maze):
        return []
    coordinates = coordi(maze)
    

    Here, you run coordi(maze) and you check if it actually returned a path or if it returned None. And when it returns a path, you run it AGAIN to store that path in the variable coordinates. This function contains about all the complexity of the kata, so you're basically running your whole program twice on every valid maze.
    Just changing this to run the function once instead of twice is enough to validate in ~10s, then you can see how other warriors implemented if you want to go further.

    coordinates = coordi(maze)
    if not coordinates:
        return []
    
  • Custom User Avatar

    As Blind4Basic said, you can print the maze you're failing to solve with a simple print of the input (i.e: print("\n".join(maze))). If it may help, the error traceback tells you that you fail while trying to solve an unsolvable maze (meaning the maze is semantically valid, but there is no way out), on the line current = visited[current] where current has value (0, 4). That seems to make sense because the cell [0, 4] is not reachable by the player in this maze ;)

    @B4B: How on Earth can you be so reactive on puzzles that you did not even create? Are you actually a robot ? :D

  • Custom User Avatar

    you have access to them: just print the input to the console.

  • Custom User Avatar

    mmmmmh.... Lemme think about it again...

    Well, there are actually 2 approaches. One is to do some/most of the work with regexp, carfully/wisely choosing what stuff you remove. The other is to scan one time through the whole string nd gather all the data you need "one shot", making the simplifications and transpiling on the fly.

    From there, it's hard to tell what will or will not do with the regex approach. I personaly used the other method, actually...

  • Custom User Avatar

    (deleted: double post again... x/ )

  • Custom User Avatar

    this way , you're still going through the whole string for each element of legal and illegal. CCL: build one single regex that will do all the replacements one shot. ;)

  • Custom User Avatar
    • your replacement of illegal parts is bad: you go through the entire string for each replacment => use regexp instead.
    • don't use string concatenation (your output).