48 const std::array<std::array<int, size>, size> &maze,
49 std::array<std::array<int, size>, size> soln) {
50 if ((currposrow == size - 1) && (currposcol == size - 1)) {
51 soln[currposrow][currposcol] = 1;
52 for (
int i = 0; i < size; ++i) {
53 for (
int j = 0; j < size; ++j) {
54 std::cout << soln[i][j] <<
" ";
56 std::cout << std::endl;
60 soln[currposrow][currposcol] = 1;
63 if ((currposcol < size - 1) && maze[currposrow][currposcol + 1] == 1 &&
64 solveMaze(currposrow, currposcol + 1, maze, soln)) {
69 if ((currposrow < size - 1) && maze[currposrow + 1][currposcol] == 1 &&
70 solveMaze(currposrow + 1, currposcol, maze, soln)) {
75 soln[currposrow][currposcol] = 0;
88 std::array<std::array<int, size>, size> maze = {
89 std::array<int, size>{1, 0, 1, 0}, std::array<int, size>{1, 0, 1, 1},
90 std::array<int, size>{1, 0, 0, 1}, std::array<int, size>{1, 1, 1, 1}};
92 std::array<std::array<int, size>, size> soln{};
95 for (
int i = 0; i < size; ++i) {
96 for (
int j = 0; j < size; ++j) {
104 assert(backtracking::rat_maze::solveMaze<size>(currposrow, currposcol, maze,
bool 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.