(String scramble)
| 100 | } |
| 101 | |
| 102 | public static int[] image(String scramble) { |
| 103 | for (int i = 0; i < 9; i++) pz[i] = i; |
| 104 | int blank = 8; |
| 105 | String[] s = scramble.split(" "); |
| 106 | for (int i = 0; i < s.length; i++) { |
| 107 | if (s[i].length() > 0) { |
| 108 | int move = "DURL".indexOf(s[i].charAt(0)); |
| 109 | int next = moveIdx[blank][move]; |
| 110 | if (next != -1) { |
| 111 | Utils.swap(pz, blank, next); |
| 112 | blank = next; |
| 113 | } |
| 114 | if (s[i].length() > 1 && s[i].charAt(1) == '2') { |
| 115 | next = moveIdx[blank][move]; |
| 116 | if (next != -1) { |
| 117 | Utils.swap(pz, blank, next); |
| 118 | blank = next; |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | return pz; |
| 124 | } |
| 125 | } |
no test coverage detected