Grid:6ร—6
1x
Recursion & Backtracking

Rat in a Maze

Step 1 of 6

A classic backtracking problem where a rat must find a path from the top-left to the bottom-right corner of a maze, exploring all possible routes.

The Setup

The maze is an Nร—N grid. Each cell is either open (passable) or a wall (blocked). The rat starts at (0,0) and must reach (N-1,N-1). Walls are generated randomly but the maze is always guaranteed to have at least one solution.

๐Ÿ€ Rat
โ— Path
โœ• Backtrack
โ— Solution