有了解题思路,对于一般性的算法题,只要动脑子想想关键点的实现方法,基本上都能写出来。
而剩余的工作就是到网上搜搜,是否有其它解决方法,对自己的思维也是一个锻炼。
1:借助栈,深度遍历思想。
2:当访问某点时,可能会遇到哪些不同的情况,以及针对不同情况的不同处理方案,比如死胡同,环路问题,遇到终点等。
3:如何依次访问某点的,正上,正右,正下,正左,四个邻接点。
4:我们对迷宫增加一圈外墙,可以简化一点逻辑。
5:只有正北墙上的起点可进行迷宫,只有正南墙上的终点可以出迷宫。
迷宫求解的基本思想
--------------------------------------------------------------------------------------------------------------------------
寻找迷宫所有可行路径,基于深度遍历
步骤1:将起点入栈
步骤2:取出当前栈顶元素,但不弹出
步骤3:按顺时针方向,分别访问栈顶元素的正上,正右,正下,正左四个邻接点
步骤4:如果不是死胡同,且如果是墙,则返回;
如果已在当前路径中,则返回;
如果超出边界,则返回;
如果是终点,则打印路径;
否则,将这个邻接点压入栈顶,继续步骤2
步骤5:如果是死胡同,则弹出栈顶元素,继续步骤2
--------------------------------------------------------------------------------------------------------------------------
代码实现如下,有详细注释
package com.collonn.algorithm.grf; import java.util.Random; import java.util.Scanner; import java.util.Stack; /** * 二维矩阵某元素的坐标 */ class Point { // 第几行 public int i; // 第几列 public int j; // 已读取的邻接元素个数,0读取正上,1读取正右,2读取正下,3读取正左 public int t; public Point(int i, int j) { this.i = i; this.j = j; } // 该元素是否是死胡同(该元素的,正上,正右,正下,正左,四个方向都找不到终点) public boolean deadEnd() { return t > 3 ? true : false; } // 以某元素为中心,按顺时针方向,依次取该元素的,正上,正右,正下,正左,四个邻接元素 // 如果超出边界,则返回null,如果这四个邻接元素都获取过,则返回null public Point getNeighBour() { Point point = null; switch (t) { // 正上元素 case 0: { if (this.i > 0) { point = new Point(this.i - 1, j); } break; } // 正右元素 case 1: { point = new Point(i, j + 1); break; } // 正下元素 case 2: { point = new Point(i + 1, j); break; } // 正左元素 case 3: { point = new Point(i, j - 1); break; } default: { return point; } } t++; return point; } // 重写equals()方法 @Override public boolean equals(Object obj) { if (!(obj instanceof Point)) { return false; } Point point = (Point) obj; if (point.i == this.i && point.j == this.j) { return true; } else { return false; } } // 重写hashCode()方法 @Override public int hashCode() { return (String.valueOf(i) + String.valueOf(j)).hashCode(); } } /** * 迷宫求解(二维矩阵) */ public class Maze { // 迷宫的二维矩阵存储 private int[][] matirx; // 迷宫起点 private Point start; // 迷宫终点 private Point end; public Maze(int i, int j) { this.matirx = new int[i][j]; System.out.printf("\nmatirx, i=%d, j=%d", i, j); } // 打印普通迷宫 private void printMatrix() { System.out.printf("\n----------------- matrix -----------------"); System.out.printf("\n%4s", ""); for (int i = 0; i < this.matirx.length; i++) { System.out.printf("%2d", i); } System.out.printf("\n----"); for (int i = 0; i < this.matirx.length; i++) { System.out.printf("%s", "--"); } System.out.printf("\n"); for (int i = 0; i < this.matirx.length; i++) { System.out.printf("%2s%2s", i, "|"); for (int j = 0; j < this.matirx[0].length; j++) { System.out.printf("%2d", this.matirx[i][j]); } System.out.print("\n"); } System.out.println("----------------- matrix -----------------"); } // 迷宫手动初始化 private void initMaze2() { this.start = new Point(0, 3); this.end = new Point(8, 6); this.matirx = new int[9][9]; // ------------------------{0, 1, 2, 3, 4, 5, 6, 7, 8} this.matirx[0] = new int[] { 1, 1, 1, 0, 1, 1, 1, 1, 1 }; this.matirx[1] = new int[] { 1, 1, 1, 0, 0, 0, 0, 0, 1 }; this.matirx[2] = new int[] { 1, 1, 1, 0, 1, 1, 0, 1, 1 }; this.matirx[3] = new int[] { 1, 0, 0, 0, 0, 0, 1, 1, 1 }; this.matirx[4] = new int[] { 1, 0, 1, 1, 1, 0, 1, 1, 1 }; this.matirx[5] = new int[] { 1, 0, 0, 0, 0, 0, 1, 1, 1 }; this.matirx[6] = new int[] { 1, 1, 0, 1, 0, 0, 0, 1, 1 }; this.matirx[7] = new int[] { 1, 1, 0, 0, 0, 1, 0, 1, 1 }; this.matirx[8] = new int[] { 1, 1, 1, 1, 1, 1, 0, 1, 1 }; } // 迷宫自动初始化 private void initMaze() { int i = this.matirx.length; int j = this.matirx[0].length; this.matirx = new int[i][j]; // 初始全部设置为墙 for (int m = 0; m < i; m++) { for (int n = 0; n < j; n++) { this.matirx[m][n] = 1; } } // 随机设置通行点 Random rd = new Random(); int ii = -1; int jj = -1; for (int k = 0; k < (i * j) / 2; k++) { ii = rd.nextInt(i); jj = rd.nextInt(j); // 不设置矩阵的四条边 if (ii == 0 || ii == (this.matirx.length - 1) || jj == 0 || jj == (this.matirx[0].length - 1)) { continue; } this.matirx[ii][jj] = 0; } // 将起点与终点设置为通行点 this.matirx[this.start.i][this.start.j] = 0; this.matirx[this.end.i][this.end.j] = 0; } // ---------------------------------- 输入迷宫的起点与终点开始 ---------------------------------- // 控制台输入迷宫起点 private void startPoint() throws Exception { while (true) { Scanner scanner = new Scanner(System.in); int i = 0; System.out.printf("\nstart.j:"); int j = scanner.nextInt(); this.start = new Point(i, j); if (!this.checkPoint(this.start)) { System.out.printf("\nnot a valid number, enter again."); continue; } this.matirx[this.start.i][this.start.j] = 0; System.out.printf("\nStart Point, i=%d, j=%d", this.start.i, this.start.j); break; } } // 控制台输入迷宫终点 private void endPoint() throws Exception { while (true) { Scanner scanner = new Scanner(System.in); int i = this.matirx.length - 1; System.out.printf("\nend.j:"); int j = scanner.nextInt(); this.end = new Point(i, j); if (!this.checkPoint(this.end)) { System.out.printf("\nnot a valid number, enter again."); continue; } this.matirx[this.end.i][this.end.j] = 0; System.out.printf("\nEnd Point, i=%d, j=%d", this.end.i, this.end.j); break; } } // 检查输入的起点与终点是否合法 private boolean checkPoint(Point point) { boolean flag = true; if (point.i >= this.matirx.length) { flag = false; } if (point.j >= this.matirx[0].length) { flag = false; } return flag; } // ---------------------------------- 输入迷宫的起点与终点结束 ---------------------------------- /** * <pre> * 寻找迷宫所有可行路径,基于深度遍历 * 步骤1:将起点入栈 * 步骤2:取出当前栈顶元素,但不弹出 * 步骤3:按顺时针方向,分别访问栈顶元素的正上,正右,正下,正左四个邻接点 * 步骤4:如果不是死胡同,且 * 如果是墙,则返回; * 如果已在当前路径中,则返回; * 如果超出边界,则返回; * 如果是终点,则打印路径; * 否则,将这个邻接点压入栈顶,继续步骤2 * 步骤5:如果是死胡同,则弹出栈顶元素,继续步骤2 * </pre> * * @param i 行 * @param j 行 * @throws Exception */ private void search() throws Exception { // 用户存储路径的当前栈 Stack<Point> stack = new Stack<Point>(); // 将起点压入栈顶 stack.push(this.start); // 寻找路径,直到栈为空 out: while (!stack.isEmpty()) { // 访问当前栈顶元素,但不弹出 Point top = stack.peek(); System.out.printf("\ntop,[%2d,%2d],", top.i, top.j); // 是否是死胡同 while (!top.deadEnd()) { // 按上右下左,顺时针方向,依次访问栈顶元素的邻接点 Point next = top.getNeighBour(); // 起点的正上为null if (next == null) { continue; } System.out.printf("\nnext,[%2d,%2d],", next.i, next.j); // 探测的下一个元素不能是当前路径中的元素(即产生回路时直接探测下一个邻接点) if (stack.contains(next)) { System.out.printf("\nstack contains,[%2d,%2d],", next.i, next.j); continue; } // 遇到墙时,直接探测下一个邻接点 if (this.matirx[next.i][next.j] == 1) { System.out.printf("\nwall,[%2d,%2d],", next.i, next.j); continue; } // 遇到终点时,打印当前路径 if (next.equals(this.end)) { stack.push(next); printPath(stack); stack.pop(); continue; } System.out.printf("\npush,[%2d,%2d],", next.i, next.j); stack.push(next); continue out; } // 某元素的,正上,正右,正下,正左,四个邻接元素都探测过,没有出路,弹出栈顶元素 stack.pop(); System.out.printf("\npop,[%2d,%2d],", top.i, top.j); } System.out.printf("\nterminal..."); } // 打印路径 private void printPath(Stack<Point> stack) { System.out.printf("\n...................... find path start ......................"); System.out.printf("\n"); // for (Point p : stack) { // System.out.printf("[%2d,%2d],", p.i, p.j); // this.matirx[p.i][p.j] = 9; // } for (int i = 0; i < this.matirx.length; i++) { System.out.printf("\n"); for (int j = 0; j < this.matirx[0].length; j++) { if (stack.contains(new Point(i, j))) { System.out.printf("%2s", "#"); } else { System.out.printf("%2s", this.matirx[i][j]); } } } System.out.printf("\n...................... find path enddd ......................"); } public static void main(String[] args) throws Exception { Maze maze = new Maze(9, 9); // maze.enterStartPoint(); // maze.enterEndPoint(); // maze.initMaze(); maze.initMaze2(); maze.printMatrix(); maze.search(); } }
打印出的探索路径如下:
matirx, i=9, j=9
----------------- matrix -----------------
0 1 2 3 4 5 6 7 8
----------------------
0 | 1 1 1 0 1 1 1 1 1
1 | 1 1 1 0 0 0 0 0 1
2 | 1 1 1 0 1 1 0 1 1
3 | 1 0 0 0 0 0 1 1 1
4 | 1 0 1 1 1 0 1 1 1
5 | 1 0 0 0 0 0 1 1 1
6 | 1 1 0 1 0 0 0 1 1
7 | 1 1 0 0 0 1 0 1 1
8 | 1 1 1 1 1 1 0 1 1
----------------- matrix -----------------
top,[ 0, 3],
next,[ 0, 4],
wall,[ 0, 4],
next,[ 1, 3],
push,[ 1, 3],
top,[ 1, 3],
next,[ 0, 3],
stack contains,[ 0, 3],
next,[ 1, 4],
push,[ 1, 4],
top,[ 1, 4],
next,[ 0, 4],
wall,[ 0, 4],
next,[ 1, 5],
push,[ 1, 5],
top,[ 1, 5],
next,[ 0, 5],
wall,[ 0, 5],
next,[ 1, 6],
push,[ 1, 6],
top,[ 1, 6],
next,[ 0, 6],
wall,[ 0, 6],
next,[ 1, 7],
push,[ 1, 7],
top,[ 1, 7],
next,[ 0, 7],
wall,[ 0, 7],
next,[ 1, 8],
wall,[ 1, 8],
next,[ 2, 7],
wall,[ 2, 7],
next,[ 1, 6],
stack contains,[ 1, 6],
pop,[ 1, 7],
top,[ 1, 6],
next,[ 2, 6],
push,[ 2, 6],
top,[ 2, 6],
next,[ 1, 6],
stack contains,[ 1, 6],
next,[ 2, 7],
wall,[ 2, 7],
next,[ 3, 6],
wall,[ 3, 6],
next,[ 2, 5],
wall,[ 2, 5],
pop,[ 2, 6],
top,[ 1, 6],
next,[ 1, 5],
stack contains,[ 1, 5],
pop,[ 1, 6],
top,[ 1, 5],
next,[ 2, 5],
wall,[ 2, 5],
next,[ 1, 4],
stack contains,[ 1, 4],
pop,[ 1, 5],
top,[ 1, 4],
next,[ 2, 4],
wall,[ 2, 4],
next,[ 1, 3],
stack contains,[ 1, 3],
pop,[ 1, 4],
top,[ 1, 3],
next,[ 2, 3],
push,[ 2, 3],
top,[ 2, 3],
next,[ 1, 3],
stack contains,[ 1, 3],
next,[ 2, 4],
wall,[ 2, 4],
next,[ 3, 3],
push,[ 3, 3],
top,[ 3, 3],
next,[ 2, 3],
stack contains,[ 2, 3],
next,[ 3, 4],
push,[ 3, 4],
top,[ 3, 4],
next,[ 2, 4],
wall,[ 2, 4],
next,[ 3, 5],
push,[ 3, 5],
top,[ 3, 5],
next,[ 2, 5],
wall,[ 2, 5],
next,[ 3, 6],
wall,[ 3, 6],
next,[ 4, 5],
push,[ 4, 5],
top,[ 4, 5],
next,[ 3, 5],
stack contains,[ 3, 5],
next,[ 4, 6],
wall,[ 4, 6],
next,[ 5, 5],
push,[ 5, 5],
top,[ 5, 5],
next,[ 4, 5],
stack contains,[ 4, 5],
next,[ 5, 6],
wall,[ 5, 6],
next,[ 6, 5],
push,[ 6, 5],
top,[ 6, 5],
next,[ 5, 5],
stack contains,[ 5, 5],
next,[ 6, 6],
push,[ 6, 6],
top,[ 6, 6],
next,[ 5, 6],
wall,[ 5, 6],
next,[ 6, 7],
wall,[ 6, 7],
next,[ 7, 6],
push,[ 7, 6],
top,[ 7, 6],
next,[ 6, 6],
stack contains,[ 6, 6],
next,[ 7, 7],
wall,[ 7, 7],
next,[ 8, 6],
...................... find path start ......................
1 1 1 # 1 1 1 1 1
1 1 1 # 0 0 0 0 1
1 1 1 # 1 1 0 1 1
1 0 0 # # # 1 1 1
1 0 1 1 1 # 1 1 1
1 0 0 0 0 # 1 1 1
1 1 0 1 0 # # 1 1
1 1 0 0 0 1 # 1 1
1 1 1 1 1 1 # 1 1
...................... find path enddd ......................
next,[ 7, 5],
wall,[ 7, 5],
pop,[ 7, 6],
top,[ 6, 6],
next,[ 6, 5],
stack contains,[ 6, 5],
pop,[ 6, 6],
top,[ 6, 5],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 6, 4],
push,[ 6, 4],
top,[ 6, 4],
next,[ 5, 4],
push,[ 5, 4],
top,[ 5, 4],
next,[ 4, 4],
wall,[ 4, 4],
next,[ 5, 5],
stack contains,[ 5, 5],
next,[ 6, 4],
stack contains,[ 6, 4],
next,[ 5, 3],
push,[ 5, 3],
top,[ 5, 3],
next,[ 4, 3],
wall,[ 4, 3],
next,[ 5, 4],
stack contains,[ 5, 4],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 5, 2],
push,[ 5, 2],
top,[ 5, 2],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 5, 3],
stack contains,[ 5, 3],
next,[ 6, 2],
push,[ 6, 2],
top,[ 6, 2],
next,[ 5, 2],
stack contains,[ 5, 2],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 2],
push,[ 7, 2],
top,[ 7, 2],
next,[ 6, 2],
stack contains,[ 6, 2],
next,[ 7, 3],
push,[ 7, 3],
top,[ 7, 3],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 4],
push,[ 7, 4],
top,[ 7, 4],
next,[ 6, 4],
stack contains,[ 6, 4],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 8, 4],
wall,[ 8, 4],
next,[ 7, 3],
stack contains,[ 7, 3],
pop,[ 7, 4],
top,[ 7, 3],
next,[ 8, 3],
wall,[ 8, 3],
next,[ 7, 2],
stack contains,[ 7, 2],
pop,[ 7, 3],
top,[ 7, 2],
next,[ 8, 2],
wall,[ 8, 2],
next,[ 7, 1],
wall,[ 7, 1],
pop,[ 7, 2],
top,[ 6, 2],
next,[ 6, 1],
wall,[ 6, 1],
pop,[ 6, 2],
top,[ 5, 2],
next,[ 5, 1],
push,[ 5, 1],
top,[ 5, 1],
next,[ 4, 1],
push,[ 4, 1],
top,[ 4, 1],
next,[ 3, 1],
push,[ 3, 1],
top,[ 3, 1],
next,[ 2, 1],
wall,[ 2, 1],
next,[ 3, 2],
push,[ 3, 2],
top,[ 3, 2],
next,[ 2, 2],
wall,[ 2, 2],
next,[ 3, 3],
stack contains,[ 3, 3],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 3, 1],
stack contains,[ 3, 1],
pop,[ 3, 2],
top,[ 3, 1],
next,[ 4, 1],
stack contains,[ 4, 1],
next,[ 3, 0],
wall,[ 3, 0],
pop,[ 3, 1],
top,[ 4, 1],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 5, 1],
stack contains,[ 5, 1],
next,[ 4, 0],
wall,[ 4, 0],
pop,[ 4, 1],
top,[ 5, 1],
next,[ 5, 2],
stack contains,[ 5, 2],
next,[ 6, 1],
wall,[ 6, 1],
next,[ 5, 0],
wall,[ 5, 0],
pop,[ 5, 1],
top,[ 5, 2],
pop,[ 5, 2],
top,[ 5, 3],
pop,[ 5, 3],
top,[ 5, 4],
pop,[ 5, 4],
top,[ 6, 4],
next,[ 6, 5],
stack contains,[ 6, 5],
next,[ 7, 4],
push,[ 7, 4],
top,[ 7, 4],
next,[ 6, 4],
stack contains,[ 6, 4],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 8, 4],
wall,[ 8, 4],
next,[ 7, 3],
push,[ 7, 3],
top,[ 7, 3],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 4],
stack contains,[ 7, 4],
next,[ 8, 3],
wall,[ 8, 3],
next,[ 7, 2],
push,[ 7, 2],
top,[ 7, 2],
next,[ 6, 2],
push,[ 6, 2],
top,[ 6, 2],
next,[ 5, 2],
push,[ 5, 2],
top,[ 5, 2],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 5, 3],
push,[ 5, 3],
top,[ 5, 3],
next,[ 4, 3],
wall,[ 4, 3],
next,[ 5, 4],
push,[ 5, 4],
top,[ 5, 4],
next,[ 4, 4],
wall,[ 4, 4],
next,[ 5, 5],
stack contains,[ 5, 5],
next,[ 6, 4],
stack contains,[ 6, 4],
next,[ 5, 3],
stack contains,[ 5, 3],
pop,[ 5, 4],
top,[ 5, 3],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 5, 2],
stack contains,[ 5, 2],
pop,[ 5, 3],
top,[ 5, 2],
next,[ 6, 2],
stack contains,[ 6, 2],
next,[ 5, 1],
push,[ 5, 1],
top,[ 5, 1],
next,[ 4, 1],
push,[ 4, 1],
top,[ 4, 1],
next,[ 3, 1],
push,[ 3, 1],
top,[ 3, 1],
next,[ 2, 1],
wall,[ 2, 1],
next,[ 3, 2],
push,[ 3, 2],
top,[ 3, 2],
next,[ 2, 2],
wall,[ 2, 2],
next,[ 3, 3],
stack contains,[ 3, 3],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 3, 1],
stack contains,[ 3, 1],
pop,[ 3, 2],
top,[ 3, 1],
next,[ 4, 1],
stack contains,[ 4, 1],
next,[ 3, 0],
wall,[ 3, 0],
pop,[ 3, 1],
top,[ 4, 1],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 5, 1],
stack contains,[ 5, 1],
next,[ 4, 0],
wall,[ 4, 0],
pop,[ 4, 1],
top,[ 5, 1],
next,[ 5, 2],
stack contains,[ 5, 2],
next,[ 6, 1],
wall,[ 6, 1],
next,[ 5, 0],
wall,[ 5, 0],
pop,[ 5, 1],
top,[ 5, 2],
pop,[ 5, 2],
top,[ 6, 2],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 2],
stack contains,[ 7, 2],
next,[ 6, 1],
wall,[ 6, 1],
pop,[ 6, 2],
top,[ 7, 2],
next,[ 7, 3],
stack contains,[ 7, 3],
next,[ 8, 2],
wall,[ 8, 2],
next,[ 7, 1],
wall,[ 7, 1],
pop,[ 7, 2],
top,[ 7, 3],
pop,[ 7, 3],
top,[ 7, 4],
pop,[ 7, 4],
top,[ 6, 4],
next,[ 6, 3],
wall,[ 6, 3],
pop,[ 6, 4],
top,[ 6, 5],
pop,[ 6, 5],
top,[ 5, 5],
next,[ 5, 4],
push,[ 5, 4],
top,[ 5, 4],
next,[ 4, 4],
wall,[ 4, 4],
next,[ 5, 5],
stack contains,[ 5, 5],
next,[ 6, 4],
push,[ 6, 4],
top,[ 6, 4],
next,[ 5, 4],
stack contains,[ 5, 4],
next,[ 6, 5],
push,[ 6, 5],
top,[ 6, 5],
next,[ 5, 5],
stack contains,[ 5, 5],
next,[ 6, 6],
push,[ 6, 6],
top,[ 6, 6],
next,[ 5, 6],
wall,[ 5, 6],
next,[ 6, 7],
wall,[ 6, 7],
next,[ 7, 6],
push,[ 7, 6],
top,[ 7, 6],
next,[ 6, 6],
stack contains,[ 6, 6],
next,[ 7, 7],
wall,[ 7, 7],
next,[ 8, 6],
...................... find path start ......................
1 1 1 # 1 1 1 1 1
1 1 1 # 0 0 0 0 1
1 1 1 # 1 1 0 1 1
1 0 0 # # # 1 1 1
1 0 1 1 1 # 1 1 1
1 0 0 0 # # 1 1 1
1 1 0 1 # # # 1 1
1 1 0 0 0 1 # 1 1
1 1 1 1 1 1 # 1 1
...................... find path enddd ......................
next,[ 7, 5],
wall,[ 7, 5],
pop,[ 7, 6],
top,[ 6, 6],
next,[ 6, 5],
stack contains,[ 6, 5],
pop,[ 6, 6],
top,[ 6, 5],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 6, 4],
stack contains,[ 6, 4],
pop,[ 6, 5],
top,[ 6, 4],
next,[ 7, 4],
push,[ 7, 4],
top,[ 7, 4],
next,[ 6, 4],
stack contains,[ 6, 4],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 8, 4],
wall,[ 8, 4],
next,[ 7, 3],
push,[ 7, 3],
top,[ 7, 3],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 4],
stack contains,[ 7, 4],
next,[ 8, 3],
wall,[ 8, 3],
next,[ 7, 2],
push,[ 7, 2],
top,[ 7, 2],
next,[ 6, 2],
push,[ 6, 2],
top,[ 6, 2],
next,[ 5, 2],
push,[ 5, 2],
top,[ 5, 2],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 5, 3],
push,[ 5, 3],
top,[ 5, 3],
next,[ 4, 3],
wall,[ 4, 3],
next,[ 5, 4],
stack contains,[ 5, 4],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 5, 2],
stack contains,[ 5, 2],
pop,[ 5, 3],
top,[ 5, 2],
next,[ 6, 2],
stack contains,[ 6, 2],
next,[ 5, 1],
push,[ 5, 1],
top,[ 5, 1],
next,[ 4, 1],
push,[ 4, 1],
top,[ 4, 1],
next,[ 3, 1],
push,[ 3, 1],
top,[ 3, 1],
next,[ 2, 1],
wall,[ 2, 1],
next,[ 3, 2],
push,[ 3, 2],
top,[ 3, 2],
next,[ 2, 2],
wall,[ 2, 2],
next,[ 3, 3],
stack contains,[ 3, 3],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 3, 1],
stack contains,[ 3, 1],
pop,[ 3, 2],
top,[ 3, 1],
next,[ 4, 1],
stack contains,[ 4, 1],
next,[ 3, 0],
wall,[ 3, 0],
pop,[ 3, 1],
top,[ 4, 1],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 5, 1],
stack contains,[ 5, 1],
next,[ 4, 0],
wall,[ 4, 0],
pop,[ 4, 1],
top,[ 5, 1],
next,[ 5, 2],
stack contains,[ 5, 2],
next,[ 6, 1],
wall,[ 6, 1],
next,[ 5, 0],
wall,[ 5, 0],
pop,[ 5, 1],
top,[ 5, 2],
pop,[ 5, 2],
top,[ 6, 2],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 2],
stack contains,[ 7, 2],
next,[ 6, 1],
wall,[ 6, 1],
pop,[ 6, 2],
top,[ 7, 2],
next,[ 7, 3],
stack contains,[ 7, 3],
next,[ 8, 2],
wall,[ 8, 2],
next,[ 7, 1],
wall,[ 7, 1],
pop,[ 7, 2],
top,[ 7, 3],
pop,[ 7, 3],
top,[ 7, 4],
pop,[ 7, 4],
top,[ 6, 4],
next,[ 6, 3],
wall,[ 6, 3],
pop,[ 6, 4],
top,[ 5, 4],
next,[ 5, 3],
push,[ 5, 3],
top,[ 5, 3],
next,[ 4, 3],
wall,[ 4, 3],
next,[ 5, 4],
stack contains,[ 5, 4],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 5, 2],
push,[ 5, 2],
top,[ 5, 2],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 5, 3],
stack contains,[ 5, 3],
next,[ 6, 2],
push,[ 6, 2],
top,[ 6, 2],
next,[ 5, 2],
stack contains,[ 5, 2],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 2],
push,[ 7, 2],
top,[ 7, 2],
next,[ 6, 2],
stack contains,[ 6, 2],
next,[ 7, 3],
push,[ 7, 3],
top,[ 7, 3],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 4],
push,[ 7, 4],
top,[ 7, 4],
next,[ 6, 4],
push,[ 6, 4],
top,[ 6, 4],
next,[ 5, 4],
stack contains,[ 5, 4],
next,[ 6, 5],
push,[ 6, 5],
top,[ 6, 5],
next,[ 5, 5],
stack contains,[ 5, 5],
next,[ 6, 6],
push,[ 6, 6],
top,[ 6, 6],
next,[ 5, 6],
wall,[ 5, 6],
next,[ 6, 7],
wall,[ 6, 7],
next,[ 7, 6],
push,[ 7, 6],
top,[ 7, 6],
next,[ 6, 6],
stack contains,[ 6, 6],
next,[ 7, 7],
wall,[ 7, 7],
next,[ 8, 6],
...................... find path start ......................
1 1 1 # 1 1 1 1 1
1 1 1 # 0 0 0 0 1
1 1 1 # 1 1 0 1 1
1 0 0 # # # 1 1 1
1 0 1 1 1 # 1 1 1
1 0 # # # # 1 1 1
1 1 # 1 # # # 1 1
1 1 # # # 1 # 1 1
1 1 1 1 1 1 # 1 1
...................... find path enddd ......................
next,[ 7, 5],
wall,[ 7, 5],
pop,[ 7, 6],
top,[ 6, 6],
next,[ 6, 5],
stack contains,[ 6, 5],
pop,[ 6, 6],
top,[ 6, 5],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 6, 4],
stack contains,[ 6, 4],
pop,[ 6, 5],
top,[ 6, 4],
next,[ 7, 4],
stack contains,[ 7, 4],
next,[ 6, 3],
wall,[ 6, 3],
pop,[ 6, 4],
top,[ 7, 4],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 8, 4],
wall,[ 8, 4],
next,[ 7, 3],
stack contains,[ 7, 3],
pop,[ 7, 4],
top,[ 7, 3],
next,[ 8, 3],
wall,[ 8, 3],
next,[ 7, 2],
stack contains,[ 7, 2],
pop,[ 7, 3],
top,[ 7, 2],
next,[ 8, 2],
wall,[ 8, 2],
next,[ 7, 1],
wall,[ 7, 1],
pop,[ 7, 2],
top,[ 6, 2],
next,[ 6, 1],
wall,[ 6, 1],
pop,[ 6, 2],
top,[ 5, 2],
next,[ 5, 1],
push,[ 5, 1],
top,[ 5, 1],
next,[ 4, 1],
push,[ 4, 1],
top,[ 4, 1],
next,[ 3, 1],
push,[ 3, 1],
top,[ 3, 1],
next,[ 2, 1],
wall,[ 2, 1],
next,[ 3, 2],
push,[ 3, 2],
top,[ 3, 2],
next,[ 2, 2],
wall,[ 2, 2],
next,[ 3, 3],
stack contains,[ 3, 3],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 3, 1],
stack contains,[ 3, 1],
pop,[ 3, 2],
top,[ 3, 1],
next,[ 4, 1],
stack contains,[ 4, 1],
next,[ 3, 0],
wall,[ 3, 0],
pop,[ 3, 1],
top,[ 4, 1],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 5, 1],
stack contains,[ 5, 1],
next,[ 4, 0],
wall,[ 4, 0],
pop,[ 4, 1],
top,[ 5, 1],
next,[ 5, 2],
stack contains,[ 5, 2],
next,[ 6, 1],
wall,[ 6, 1],
next,[ 5, 0],
wall,[ 5, 0],
pop,[ 5, 1],
top,[ 5, 2],
pop,[ 5, 2],
top,[ 5, 3],
pop,[ 5, 3],
top,[ 5, 4],
pop,[ 5, 4],
top,[ 5, 5],
pop,[ 5, 5],
top,[ 4, 5],
next,[ 4, 4],
wall,[ 4, 4],
pop,[ 4, 5],
top,[ 3, 5],
next,[ 3, 4],
stack contains,[ 3, 4],
pop,[ 3, 5],
top,[ 3, 4],
next,[ 4, 4],
wall,[ 4, 4],
next,[ 3, 3],
stack contains,[ 3, 3],
pop,[ 3, 4],
top,[ 3, 3],
next,[ 4, 3],
wall,[ 4, 3],
next,[ 3, 2],
push,[ 3, 2],
top,[ 3, 2],
next,[ 2, 2],
wall,[ 2, 2],
next,[ 3, 3],
stack contains,[ 3, 3],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 3, 1],
push,[ 3, 1],
top,[ 3, 1],
next,[ 2, 1],
wall,[ 2, 1],
next,[ 3, 2],
stack contains,[ 3, 2],
next,[ 4, 1],
push,[ 4, 1],
top,[ 4, 1],
next,[ 3, 1],
stack contains,[ 3, 1],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 5, 1],
push,[ 5, 1],
top,[ 5, 1],
next,[ 4, 1],
stack contains,[ 4, 1],
next,[ 5, 2],
push,[ 5, 2],
top,[ 5, 2],
next,[ 4, 2],
wall,[ 4, 2],
next,[ 5, 3],
push,[ 5, 3],
top,[ 5, 3],
next,[ 4, 3],
wall,[ 4, 3],
next,[ 5, 4],
push,[ 5, 4],
top,[ 5, 4],
next,[ 4, 4],
wall,[ 4, 4],
next,[ 5, 5],
push,[ 5, 5],
top,[ 5, 5],
next,[ 4, 5],
push,[ 4, 5],
top,[ 4, 5],
next,[ 3, 5],
push,[ 3, 5],
top,[ 3, 5],
next,[ 2, 5],
wall,[ 2, 5],
next,[ 3, 6],
wall,[ 3, 6],
next,[ 4, 5],
stack contains,[ 4, 5],
next,[ 3, 4],
push,[ 3, 4],
top,[ 3, 4],
next,[ 2, 4],
wall,[ 2, 4],
next,[ 3, 5],
stack contains,[ 3, 5],
next,[ 4, 4],
wall,[ 4, 4],
next,[ 3, 3],
stack contains,[ 3, 3],
pop,[ 3, 4],
top,[ 3, 5],
pop,[ 3, 5],
top,[ 4, 5],
next,[ 4, 6],
wall,[ 4, 6],
next,[ 5, 5],
stack contains,[ 5, 5],
next,[ 4, 4],
wall,[ 4, 4],
pop,[ 4, 5],
top,[ 5, 5],
next,[ 5, 6],
wall,[ 5, 6],
next,[ 6, 5],
push,[ 6, 5],
top,[ 6, 5],
next,[ 5, 5],
stack contains,[ 5, 5],
next,[ 6, 6],
push,[ 6, 6],
top,[ 6, 6],
next,[ 5, 6],
wall,[ 5, 6],
next,[ 6, 7],
wall,[ 6, 7],
next,[ 7, 6],
push,[ 7, 6],
top,[ 7, 6],
next,[ 6, 6],
stack contains,[ 6, 6],
next,[ 7, 7],
wall,[ 7, 7],
next,[ 8, 6],
...................... find path start ......................
1 1 1 # 1 1 1 1 1
1 1 1 # 0 0 0 0 1
1 1 1 # 1 1 0 1 1
1 # # # 0 0 1 1 1
1 # 1 1 1 0 1 1 1
1 # # # # # 1 1 1
1 1 0 1 0 # # 1 1
1 1 0 0 0 1 # 1 1
1 1 1 1 1 1 # 1 1
...................... find path enddd ......................
next,[ 7, 5],
wall,[ 7, 5],
pop,[ 7, 6],
top,[ 6, 6],
next,[ 6, 5],
stack contains,[ 6, 5],
pop,[ 6, 6],
top,[ 6, 5],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 6, 4],
push,[ 6, 4],
top,[ 6, 4],
next,[ 5, 4],
stack contains,[ 5, 4],
next,[ 6, 5],
stack contains,[ 6, 5],
next,[ 7, 4],
push,[ 7, 4],
top,[ 7, 4],
next,[ 6, 4],
stack contains,[ 6, 4],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 8, 4],
wall,[ 8, 4],
next,[ 7, 3],
push,[ 7, 3],
top,[ 7, 3],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 4],
stack contains,[ 7, 4],
next,[ 8, 3],
wall,[ 8, 3],
next,[ 7, 2],
push,[ 7, 2],
top,[ 7, 2],
next,[ 6, 2],
push,[ 6, 2],
top,[ 6, 2],
next,[ 5, 2],
stack contains,[ 5, 2],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 2],
stack contains,[ 7, 2],
next,[ 6, 1],
wall,[ 6, 1],
pop,[ 6, 2],
top,[ 7, 2],
next,[ 7, 3],
stack contains,[ 7, 3],
next,[ 8, 2],
wall,[ 8, 2],
next,[ 7, 1],
wall,[ 7, 1],
pop,[ 7, 2],
top,[ 7, 3],
pop,[ 7, 3],
top,[ 7, 4],
pop,[ 7, 4],
top,[ 6, 4],
next,[ 6, 3],
wall,[ 6, 3],
pop,[ 6, 4],
top,[ 6, 5],
pop,[ 6, 5],
top,[ 5, 5],
next,[ 5, 4],
stack contains,[ 5, 4],
pop,[ 5, 5],
top,[ 5, 4],
next,[ 6, 4],
push,[ 6, 4],
top,[ 6, 4],
next,[ 5, 4],
stack contains,[ 5, 4],
next,[ 6, 5],
push,[ 6, 5],
top,[ 6, 5],
next,[ 5, 5],
push,[ 5, 5],
top,[ 5, 5],
next,[ 4, 5],
push,[ 4, 5],
top,[ 4, 5],
next,[ 3, 5],
push,[ 3, 5],
top,[ 3, 5],
next,[ 2, 5],
wall,[ 2, 5],
next,[ 3, 6],
wall,[ 3, 6],
next,[ 4, 5],
stack contains,[ 4, 5],
next,[ 3, 4],
push,[ 3, 4],
top,[ 3, 4],
next,[ 2, 4],
wall,[ 2, 4],
next,[ 3, 5],
stack contains,[ 3, 5],
next,[ 4, 4],
wall,[ 4, 4],
next,[ 3, 3],
stack contains,[ 3, 3],
pop,[ 3, 4],
top,[ 3, 5],
pop,[ 3, 5],
top,[ 4, 5],
next,[ 4, 6],
wall,[ 4, 6],
next,[ 5, 5],
stack contains,[ 5, 5],
next,[ 4, 4],
wall,[ 4, 4],
pop,[ 4, 5],
top,[ 5, 5],
next,[ 5, 6],
wall,[ 5, 6],
next,[ 6, 5],
stack contains,[ 6, 5],
next,[ 5, 4],
stack contains,[ 5, 4],
pop,[ 5, 5],
top,[ 6, 5],
next,[ 6, 6],
push,[ 6, 6],
top,[ 6, 6],
next,[ 5, 6],
wall,[ 5, 6],
next,[ 6, 7],
wall,[ 6, 7],
next,[ 7, 6],
push,[ 7, 6],
top,[ 7, 6],
next,[ 6, 6],
stack contains,[ 6, 6],
next,[ 7, 7],
wall,[ 7, 7],
next,[ 8, 6],
...................... find path start ......................
1 1 1 # 1 1 1 1 1
1 1 1 # 0 0 0 0 1
1 1 1 # 1 1 0 1 1
1 # # # 0 0 1 1 1
1 # 1 1 1 0 1 1 1
1 # # # # 0 1 1 1
1 1 0 1 # # # 1 1
1 1 0 0 0 1 # 1 1
1 1 1 1 1 1 # 1 1
...................... find path enddd ......................
next,[ 7, 5],
wall,[ 7, 5],
pop,[ 7, 6],
top,[ 6, 6],
next,[ 6, 5],
stack contains,[ 6, 5],
pop,[ 6, 6],
top,[ 6, 5],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 6, 4],
stack contains,[ 6, 4],
pop,[ 6, 5],
top,[ 6, 4],
next,[ 7, 4],
push,[ 7, 4],
top,[ 7, 4],
next,[ 6, 4],
stack contains,[ 6, 4],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 8, 4],
wall,[ 8, 4],
next,[ 7, 3],
push,[ 7, 3],
top,[ 7, 3],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 4],
stack contains,[ 7, 4],
next,[ 8, 3],
wall,[ 8, 3],
next,[ 7, 2],
push,[ 7, 2],
top,[ 7, 2],
next,[ 6, 2],
push,[ 6, 2],
top,[ 6, 2],
next,[ 5, 2],
stack contains,[ 5, 2],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 2],
stack contains,[ 7, 2],
next,[ 6, 1],
wall,[ 6, 1],
pop,[ 6, 2],
top,[ 7, 2],
next,[ 7, 3],
stack contains,[ 7, 3],
next,[ 8, 2],
wall,[ 8, 2],
next,[ 7, 1],
wall,[ 7, 1],
pop,[ 7, 2],
top,[ 7, 3],
pop,[ 7, 3],
top,[ 7, 4],
pop,[ 7, 4],
top,[ 6, 4],
next,[ 6, 3],
wall,[ 6, 3],
pop,[ 6, 4],
top,[ 5, 4],
next,[ 5, 3],
stack contains,[ 5, 3],
pop,[ 5, 4],
top,[ 5, 3],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 5, 2],
stack contains,[ 5, 2],
pop,[ 5, 3],
top,[ 5, 2],
next,[ 6, 2],
push,[ 6, 2],
top,[ 6, 2],
next,[ 5, 2],
stack contains,[ 5, 2],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 2],
push,[ 7, 2],
top,[ 7, 2],
next,[ 6, 2],
stack contains,[ 6, 2],
next,[ 7, 3],
push,[ 7, 3],
top,[ 7, 3],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 7, 4],
push,[ 7, 4],
top,[ 7, 4],
next,[ 6, 4],
push,[ 6, 4],
top,[ 6, 4],
next,[ 5, 4],
push,[ 5, 4],
top,[ 5, 4],
next,[ 4, 4],
wall,[ 4, 4],
next,[ 5, 5],
push,[ 5, 5],
top,[ 5, 5],
next,[ 4, 5],
push,[ 4, 5],
top,[ 4, 5],
next,[ 3, 5],
push,[ 3, 5],
top,[ 3, 5],
next,[ 2, 5],
wall,[ 2, 5],
next,[ 3, 6],
wall,[ 3, 6],
next,[ 4, 5],
stack contains,[ 4, 5],
next,[ 3, 4],
push,[ 3, 4],
top,[ 3, 4],
next,[ 2, 4],
wall,[ 2, 4],
next,[ 3, 5],
stack contains,[ 3, 5],
next,[ 4, 4],
wall,[ 4, 4],
next,[ 3, 3],
stack contains,[ 3, 3],
pop,[ 3, 4],
top,[ 3, 5],
pop,[ 3, 5],
top,[ 4, 5],
next,[ 4, 6],
wall,[ 4, 6],
next,[ 5, 5],
stack contains,[ 5, 5],
next,[ 4, 4],
wall,[ 4, 4],
pop,[ 4, 5],
top,[ 5, 5],
next,[ 5, 6],
wall,[ 5, 6],
next,[ 6, 5],
push,[ 6, 5],
top,[ 6, 5],
next,[ 5, 5],
stack contains,[ 5, 5],
next,[ 6, 6],
push,[ 6, 6],
top,[ 6, 6],
next,[ 5, 6],
wall,[ 5, 6],
next,[ 6, 7],
wall,[ 6, 7],
next,[ 7, 6],
push,[ 7, 6],
top,[ 7, 6],
next,[ 6, 6],
stack contains,[ 6, 6],
next,[ 7, 7],
wall,[ 7, 7],
next,[ 8, 6],
...................... find path start ......................
1 1 1 # 1 1 1 1 1
1 1 1 # 0 0 0 0 1
1 1 1 # 1 1 0 1 1
1 # # # 0 0 1 1 1
1 # 1 1 1 0 1 1 1
1 # # 0 # # 1 1 1
1 1 # 1 # # # 1 1
1 1 # # # 1 # 1 1
1 1 1 1 1 1 # 1 1
...................... find path enddd ......................
next,[ 7, 5],
wall,[ 7, 5],
pop,[ 7, 6],
top,[ 6, 6],
next,[ 6, 5],
stack contains,[ 6, 5],
pop,[ 6, 6],
top,[ 6, 5],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 6, 4],
stack contains,[ 6, 4],
pop,[ 6, 5],
top,[ 5, 5],
next,[ 5, 4],
stack contains,[ 5, 4],
pop,[ 5, 5],
top,[ 5, 4],
next,[ 6, 4],
stack contains,[ 6, 4],
next,[ 5, 3],
push,[ 5, 3],
top,[ 5, 3],
next,[ 4, 3],
wall,[ 4, 3],
next,[ 5, 4],
stack contains,[ 5, 4],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 5, 2],
stack contains,[ 5, 2],
pop,[ 5, 3],
top,[ 5, 4],
pop,[ 5, 4],
top,[ 6, 4],
next,[ 6, 5],
push,[ 6, 5],
top,[ 6, 5],
next,[ 5, 5],
push,[ 5, 5],
top,[ 5, 5],
next,[ 4, 5],
push,[ 4, 5],
top,[ 4, 5],
next,[ 3, 5],
push,[ 3, 5],
top,[ 3, 5],
next,[ 2, 5],
wall,[ 2, 5],
next,[ 3, 6],
wall,[ 3, 6],
next,[ 4, 5],
stack contains,[ 4, 5],
next,[ 3, 4],
push,[ 3, 4],
top,[ 3, 4],
next,[ 2, 4],
wall,[ 2, 4],
next,[ 3, 5],
stack contains,[ 3, 5],
next,[ 4, 4],
wall,[ 4, 4],
next,[ 3, 3],
stack contains,[ 3, 3],
pop,[ 3, 4],
top,[ 3, 5],
pop,[ 3, 5],
top,[ 4, 5],
next,[ 4, 6],
wall,[ 4, 6],
next,[ 5, 5],
stack contains,[ 5, 5],
next,[ 4, 4],
wall,[ 4, 4],
pop,[ 4, 5],
top,[ 5, 5],
next,[ 5, 6],
wall,[ 5, 6],
next,[ 6, 5],
stack contains,[ 6, 5],
next,[ 5, 4],
push,[ 5, 4],
top,[ 5, 4],
next,[ 4, 4],
wall,[ 4, 4],
next,[ 5, 5],
stack contains,[ 5, 5],
next,[ 6, 4],
stack contains,[ 6, 4],
next,[ 5, 3],
push,[ 5, 3],
top,[ 5, 3],
next,[ 4, 3],
wall,[ 4, 3],
next,[ 5, 4],
stack contains,[ 5, 4],
next,[ 6, 3],
wall,[ 6, 3],
next,[ 5, 2],
stack contains,[ 5, 2],
pop,[ 5, 3],
top,[ 5, 4],
pop,[ 5, 4],
top,[ 5, 5],
pop,[ 5, 5],
top,[ 6, 5],
next,[ 6, 6],
push,[ 6, 6],
top,[ 6, 6],
next,[ 5, 6],
wall,[ 5, 6],
next,[ 6, 7],
wall,[ 6, 7],
next,[ 7, 6],
push,[ 7, 6],
top,[ 7, 6],
next,[ 6, 6],
stack contains,[ 6, 6],
next,[ 7, 7],
wall,[ 7, 7],
next,[ 8, 6],
...................... find path start ......................
1 1 1 # 1 1 1 1 1
1 1 1 # 0 0 0 0 1
1 1 1 # 1 1 0 1 1
1 # # # 0 0 1 1 1
1 # 1 1 1 0 1 1 1
1 # # 0 0 0 1 1 1
1 1 # 1 # # # 1 1
1 1 # # # 1 # 1 1
1 1 1 1 1 1 # 1 1
...................... find path enddd ......................
next,[ 7, 5],
wall,[ 7, 5],
pop,[ 7, 6],
top,[ 6, 6],
next,[ 6, 5],
stack contains,[ 6, 5],
pop,[ 6, 6],
top,[ 6, 5],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 6, 4],
stack contains,[ 6, 4],
pop,[ 6, 5],
top,[ 6, 4],
next,[ 7, 4],
stack contains,[ 7, 4],
next,[ 6, 3],
wall,[ 6, 3],
pop,[ 6, 4],
top,[ 7, 4],
next,[ 7, 5],
wall,[ 7, 5],
next,[ 8, 4],
wall,[ 8, 4],
next,[ 7, 3],
stack contains,[ 7, 3],
pop,[ 7, 4],
top,[ 7, 3],
next,[ 8, 3],
wall,[ 8, 3],
next,[ 7, 2],
stack contains,[ 7, 2],
pop,[ 7, 3],
top,[ 7, 2],
next,[ 8, 2],
wall,[ 8, 2],
next,[ 7, 1],
wall,[ 7, 1],
pop,[ 7, 2],
top,[ 6, 2],
next,[ 6, 1],
wall,[ 6, 1],
pop,[ 6, 2],
top,[ 5, 2],
next,[ 5, 1],
stack contains,[ 5, 1],
pop,[ 5, 2],
top,[ 5, 1],
next,[ 6, 1],
wall,[ 6, 1],
next,[ 5, 0],
wall,[ 5, 0],
pop,[ 5, 1],
top,[ 4, 1],
next,[ 4, 0],
wall,[ 4, 0],
pop,[ 4, 1],
top,[ 3, 1],
next,[ 3, 0],
wall,[ 3, 0],
pop,[ 3, 1],
top,[ 3, 2],
pop,[ 3, 2],
top,[ 3, 3],
pop,[ 3, 3],
top,[ 2, 3],
next,[ 2, 2],
wall,[ 2, 2],
pop,[ 2, 3],
top,[ 1, 3],
next,[ 1, 2],
wall,[ 1, 2],
pop,[ 1, 3],
top,[ 0, 3],
next,[ 0, 2],
wall,[ 0, 2],
pop,[ 0, 3],
terminal...