diff --git a/sk1a/maze.c b/sk1a/maze.c index e5a49f3..e28c095 100644 --- a/sk1a/maze.c +++ b/sk1a/maze.c @@ -1 +1,36 @@ -qqq \ No newline at end of file +#include +#include +#include "maze.h" +#include +#include + +int solve_recursive(char* maze, int size, int x, int y, int down_visited); + +int solve_maze(char* maze,int size){ + int solved = solve_recursive(maze, size, 0, 0, 0); + + return 0; +} + +int solve_recursive(char* maze, int size, int x, int y, int down_visited){ + maze[x + y * size] = '*'; + if(x == size - 1 && x == y){ + return 1; + } + + if(x != size - 1 && maze[x + 1 + y * size] != 'x'){ + return solve_recursive(maze, size, x+1, y, 0); + } + + else if(y != size - 1 && maze[x + (y + 1) * size] != 'x' && down_visited != 1){ + return solve_recursive(maze, size, x, y+1, 0); + } + + else if(y != 0 && maze[x + (y - 1) * size] != 'x'){ + return solve_recursive(maze, size, x, y - 1, 1); + } + + else { + return 0; + } +}