Maze Path Finder

Backtracking Maze Pathfinding Algorithm

Maze Path Finder

Given a rectangular maze represented as a 2D grid, you need to find all possible paths from the starting point (top-left corner at (0, 0)) to the destination (bottom-right corner at (n-1, m-1)). Each cell in the maze can either be open (0) or blocked (1). You can move in four directions: up, down, left, and right. You cannot move diagonally or move outside the maze boundaries, and you cannot visit the same cell more than once in a single path.

Requirements

  • Write a function findMazePaths (or equivalent in your language) that returns all valid paths. Each path should be represented as an ordered list of coordinate pairs (e.g., [(row1, col1), (row2, col2), ...]).
  • Use a backtracking approach to explore all possible paths.
  • If there is no valid path, return an empty list.

Example

Given the maze:

0 0 1
0 0 0
1 0 0

One possible valid path might be:

[(0,0), (0,1), (1,1), (1,2), (2,2)]

Additional Note

Today (November 13) is another opportunity to exercise your problem-solving skills. Challenge yourself to write a clear and efficient solution using backtracking!

Happy coding!