|
Algorithms_in_C++
1.0.0
Set of algorithms implemented in C++.
|
Implements <a href="https://www.codesdope.com/blog/article/backtracking-to- solve-a-rat-in-a-maze-c-java-pytho/". More...
#include <array>#include <iostream>#include <cassert>Namespaces | |
| backtracking | |
| Backtracking algorithms. | |
| rat_maze | |
| Functions for <a href="https://www.codesdope.com/blog/article/backtracking-to-
solve-a-rat-in-a-maze-c-java-pytho/". | |
Functions | |
| template<size_t size> | |
| bool | backtracking::rat_maze::solveMaze (int currposrow, int currposcol, const std::array< std::array< int, size >, size > &maze, std::array< std::array< int, size >, size > soln) |
| Solve rat maze problem. More... | |
| static void | test () |
| Test implementations. More... | |
| int | main () |
| Main function. More... | |
Implements <a href="https://www.codesdope.com/blog/article/backtracking-to- solve-a-rat-in-a-maze-c-java-pytho/".
>Rat in a Maze algorithm
A Maze is given as N*N binary matrix of blocks where source block is the upper left most block i.e., maze[0][0] and destination block is lower rightmost block i.e., maze[N-1][N-1]. A rat starts from source and has to reach destination. The rat can move only in two directions: forward and down. In the maze matrix, 0 means the block is dead end and 1 means the block can be used in the path from source to destination.
| int main | ( | void | ) |
| bool backtracking::rat_maze::solveMaze | ( | int | currposrow, |
| int | currposcol, | ||
| const std::array< std::array< int, size >, size > & | maze, | ||
| std::array< std::array< int, size >, size > | soln | ||
| ) |
Solve rat maze problem.
| size | number of matrix size |
| currposrow | current position in rows |
| currposcol | current position in columns |
| maze | matrix where numbers are saved |
| soln | matrix to problem solution |
|
static |
Test implementations.