![]() |
TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Implements Rat in a Maze algorithm. More...
#include <array>#include <cassert>#include <iostream>Go to the source code of this file.
Namespaces | |
| namespace | backtracking |
| for vector container | |
| namespace | rat_maze |
| Functions for Rat in a Maze algorithm. | |
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. | |
| static void | test () |
| Self-test implementations. | |
| int | main () |
| Main function. | |
Implements 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.
Definition in file rat_maze.cpp.
| int main | ( | void | ) |
Main function.
Definition at line 112 of file rat_maze.cpp.
| 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 |
Definition at line 47 of file rat_maze.cpp.
|
static |
Self-test implementations.
Definition at line 86 of file rat_maze.cpp.