I was learning about the Rat in Maze problem on competitive coding platforms that is solved with recursion and backtracking.
Then I thought it would be fun if we could visualize it happening in front of our eyes.
That's why I wrote this program.
This program will help visualize the Rat In Maze problem just through command prompt and by live changes in matrix.
- This is the maze that the rat will traverse in this input
- Here is the video of the Rat in action!
RatInMaze.mp4
Contains the driver code and the input.
Contains the functions :-
-
findPath()- which have main code to find path with recursion and backtracking -
isSafe()- to check for 3 conditions to find out if that way to go is safe or not.
Do check code for more insight...
Compile it
gcc main.cpp -o mainRun it
./main-
You can use this program to study about how backtracking works and how it is visually seen!
-
You can use this code for your learning pupose or to teach someone about this problem.
Enjoy! 😋
~ @aliqyan21
