import java.util.*;
/*
Input                         Output
10
####################          ####################
#s#       #f   #   #          #s#       #f...#...#
# ####### #### # # #          #.####### ####.#.#.#
#         #  # ### #          #.........#..#.###.#
##### ### #        #          ##### ###.#........#
#   # #   ####### ##          #   # #...#######.##
#   # # ### #   #  #          #   # #.### #...#..#
#   # # #   # # ## #          #   # #.#...#.#.##.#
#     #   #   #    #          #     #...#...#....#
####################          ####################

 */
public class MazeRunnerRecursive {
   static Maze m;
   static Position goal;
    public static void main(String[] arguments)
    {

	m = new Maze("MazeRunner.input"); // the maze	

	goal = m.finish(); // where the finish is
	traverseMaze(m.start());
    }
   
   public static void traverseMaze(Position p)
   {

	if (!m.isVisited(p))
	    if (p.equals(goal)) {
		System.out.println(m); // print solution
	        return;}
	    else {
	    // visit this location, and add neighbors to pool
	    m.visit(p);

	    if (m.isClear(p.east())) traverseMaze(p.east());
	    if (m.isClear(p.south())) traverseMaze(p.south());	
	    if (m.isClear(p.west())) traverseMaze (p.west());
	    if (m.isClear(p.north())) traverseMaze(p.north());
	    
    }
    
}

Mark set [4 times]
(No files need saving)
