Skip to content

UPDATED rat_in_maze.py #9148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Apply suggestions from code review
  • Loading branch information
cclauss authored Oct 4, 2023
commit 80138706368c44dae678fe70ac20b2d10b220899
19 changes: 9 additions & 10 deletions backtracking/rat_in_maze.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@ def solve_maze(
"""
This method solves the "rat in maze" problem.
Parameters :
- maze(2D matrix) : maze
- source_row (int): The row index of the starting point.
- source_column (int): The column index of the starting point.
- destination_row (int): The row index of the destination point.
- destination_column (int): The column index of the destination point.
- maze: A two dimensional matrix of zeros and ones.
- source_row: The row index of the starting point.
- source_column: The column index of the starting point.
- destination_row: The row index of the destination point.
- destination_column: The column index of the destination point.
Returns:
- solution (list[list[int]]): A 2D matrix representing the solution path
if it exists.
- solution: A 2D matrix representing the solution path if it exists.
Raises:
- ValueError: If no solution exists or if the source or
destination coordinates are invalid.
Description:
This method navigates through a maze represented as an n by n matrix,
starting from a specified source cell and
starting from a specified source cell and
aiming to reach a destination cell.
The maze consists of walls (1s) and open paths (0s).
By providing custom row and column values, the source and destination
Expand Down Expand Up @@ -150,9 +149,9 @@ def run_maze(
up, down, left, right.
If a path is found to destination it returns True otherwise it returns False.
Parameters
maze(2D matrix) : maze
maze: A two dimensional matrix of zeros and ones.
i, j : coordinates of matrix
solutions(2D matrix) : solutions
solutions: A two dimensional matrix of solutions.
Returns:
Boolean if path is found True, Otherwise False.
"""
Expand Down