We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Solve the Maze

It's finally time to solve the maze!

solve() method

The solve() method on the Maze class simply calls the _solve_r method starting at i=0 and j=0. It should return True if the maze was solved, False otherwise. This is the same return value as _solve_r.

_solve_r Method

I wrote a depth-first solution to the maze, feel free to do something different if you want. Here were my steps.

The _solve_r method returns True if the current cell is an end cell, OR if it leads to the end cell. It returns False if the current cell is a loser cell.

Update the Main Function

Call maze.solve() in the main function and watch your algorithm do its work!