Maze solving algorithms in C