MCPcopy Create free account
hub / github.com/MeigenChou/DCTimer-Android / scramble

Method scramble

app/src/main/java/solver/CubeRU.java:81–110  ·  view source on GitHub ↗
(boolean lu)

Source from the content-addressed store, hash-verified

79 }
80
81 public static String scramble(boolean lu) {
82 int cp, co, ep;
83 int[] c = new int[6], e = new int[7];
84 Random r = new Random();
85 do {
86 do {
87 cp = r.nextInt(720);
88 co = r.nextInt(243);
89 }
90 while (cd[cp * 243 + co] < 0);
91 ep = r.nextInt(5040);
92 Utils.idxToPerm(c, cp, 6, false);
93 Utils.idxToPerm(e, ep, 7, false);
94 } while (permutationSign(c) != permutationSign(e));
95 for (int d = 0; d < 21; d++) {
96 if (search(cp, co, ep, d, -1)) {
97 if (d < 2) return scramble(lu);
98 if (d < 4) {
99 continue;
100 }
101 StringBuilder sb = new StringBuilder();
102 for (int i = 1; i <= d; i++) {
103 if (lu) sb.append(turnlu[seq[i] / 3]).append(suff[seq[i] % 3]).append(" ");
104 else sb.append(turn[seq[i] / 3]).append(suffInv[seq[i] % 3]).append(" ");
105 }
106 return sb.toString();
107 }
108 }
109 return "error";
110 }
111}

Callers 1

generateScrambleMethod · 0.95

Calls 4

idxToPermMethod · 0.95
searchMethod · 0.95
permutationSignMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected