Skip to content

Commit 237fb4a

Browse files
authored
Update rat_in_maze.py
Fixes TheAlgorithms#9066 Backtracking/Rat Maze TheAlgorithms#9066 I have made updates to the rat_in_maze.py file to resolve the bug to create expected output by returning (solutions,1) as tuple
1 parent dec9643 commit 237fb4a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: backtracking/rat_in_maze.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ def solve_maze(maze: list[list[int]]) -> bool:
6464
solutions = [[0 for _ in range(size)] for _ in range(size)]
6565
solved = run_maze(maze, 0, 0, solutions)
6666
if solved:
67-
print("\n".join(str(row) for row in solutions))
67+
solved=(solutions,1)
6868
else:
69-
print("No solution exists!")
69+
solved="No solution exists!"
7070
return solved
7171

7272

@@ -113,6 +113,7 @@ def run_maze(maze: list[list[int]], i: int, j: int, solutions: list[list[int]])
113113

114114

115115
if __name__ == "__main__":
116+
maze = [[0, 1, 0, 1, 1],[0, 0, 0, 0, 0],[1, 0, 1, 0, 1],[0, 0, 1, 0, 0],[1, 0, 0, 1, 0]]
117+
print(solve_maze(maze))
116118
import doctest
117-
118119
doctest.testmod()

0 commit comments

Comments
 (0)