When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
5 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
heres my code:
if (sr == er && sc == ec && maze[sr][sc] == '.') {
return true; // shows that the maze is solveable because the dot is not an obstacle
}
if (maze[sr][sc] == '@' || maze[sr][sc] == 'X' || maze[sr][sc] == 'V') {
return false; // maze is not solveable because of hole, wall, or spot visited in the past
}
maze[sr][sc] = 'V'; // marks spot as visited once you moved from the spot
bool pathPresent{};
if (maze[sr + 1][sc] != '@' || maze[sr + 1][sc] != 'X' || maze[sr + 1][sc] != 'V') {
pathPresent = connectedPath(maze, nRows, nCols, sr + 1, sc, er, ec);
return true;
}
if (maze[sr - 1][sc] != '@' || maze[sr - 1][sc] != 'X' || maze[sr - 1][sc] != 'V') {
pathPresent = connectedPath(maze, nRows, nCols, sr - 1, sc, er, ec);
return true;
}
if (maze[sr][sc + 1] != '@' || maze[sr][sc + 1] != 'X' || maze[sr][sc + 1] != 'V') {
pathPresent = connectedPath(maze, nRows, nCols, sr, sc + 1, er, ec);
return true;
}
if (maze[sr][sc - 1] != '@' || maze[sr][sc - 1] != 'X' || maze[sr][sc - 1] != 'V') {
pathPresent = connectedPath(maze, nRows, nCols, sr, sc - 1, er, ec);
return true;
}
return false;
}
i was marking in comments as i went along to sort of keep my track
@deft granite
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.
!solved