()
| 75 | |
| 76 | // sequence of boards in a shortest solution; null if unsolvable |
| 77 | public Iterable<Board> solution() { |
| 78 | if (!solvable) return null; |
| 79 | Stack<Board> p = new Stack<>(); |
| 80 | Node node = goal; |
| 81 | while (node != null) { |
| 82 | p.push(node.board); |
| 83 | node = node.prev; |
| 84 | } |
| 85 | return p; |
| 86 | } |
| 87 | |
| 88 | public static void main(String[] args) { |
| 89 | // create initial board from file |