|
Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Implements Rat in a Maze algorithm. More...
#include <array>#include <cassert>#include <iostream>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.
| 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 |
true if there exists a solution to move one step ahead in a column or in a row false for the backtracking part
|
static |
Self-test implementations.