| 62 | } |
| 63 | |
| 64 | static boolean search(int state, int d) { |
| 65 | if (d == 0) return state == 0; |
| 66 | if (prun[state] > d) return false; |
| 67 | int[] arr = new int[9]; |
| 68 | Utils.set11Perm(arr, state, 9); |
| 69 | for (int m = 0; m < 4; m++) { |
| 70 | System.arraycopy(arr, 0, pz, 0, 9); |
| 71 | for (int n = 0; n < 2; n++) { |
| 72 | int next = move(m); |
| 73 | if (next == -1) break; |
| 74 | next = Utils.get11Perm(pz, 9); |
| 75 | if (search(next, d - 1)) { |
| 76 | seq[d] = m << 1 | n; |
| 77 | return true; |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | return false; |
| 82 | } |
| 83 | |
| 84 | public static String scramble(Random r) { |
| 85 | init(); |