//Zachary Fitzsimmons import java.io.*; import java.util.*; public class BoardGame { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(new File("board.dat")); boolean[][] map = new boolean[6][6]; Stack sloc = new Stack(); Queue qloc = new LinkedList(); Stack> s_qloc = new Stack>(); Integer x = 0, y = 0; while(scan.hasNext()) { map[y][x] = scan.next().charAt(0) == 'X' ? true : false; //X is black and also true if(x == 6) { y++; x %= 6; } } findPaths(map, sloc, qloc, s_qloc, 0, 0); System.out.println(s_qloc); while(!s_qloc.empty()) { qloc = s_qloc.pop(); while(!qloc.isEmpty()) { System.out.println(qloc.remove()); } } } public static void findPaths(boolean[][] map, Stack sloc, Queue qloc, Stack> s_qloc, Integer x, Integer y) { if(map[y][x] && map[y+1][x]) { qloc.add(new Location(x, ++y)); findPaths(map, sloc, qloc, s_qloc, x, y); } if(map[y][x] && map[y][x+1]) { qloc.add(new Location(++x, y)); findPaths(map, sloc, qloc, s_qloc, x, y); } if(x == 5 && y == 5) { s_qloc.push(qloc); } } public Queue copy(Queue q) { Queue qCopy = new LinkedList(); E o = q.peek(); E e = q.remove(); while(e != null) { qCopy.add(e); q.add(e); if(q.peek() == o) e = null; else e = q.remove(); } return qCopy; } }