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

Method idxToPerm

app/src/main/java/solver/Utils.java:126–143  ·  view source on GitHub ↗
(int[] permutation, int index, int length, boolean even)

Source from the content-addressed store, hash-verified

124 }
125
126 public static void idxToPerm(int[] permutation, int index, int length, boolean even) {
127 int sum = 0;
128 if (even) {
129 permutation[length - 1] = 1;
130 permutation[length - 2] = 0;
131 } else permutation[length - 1] = 0;
132 int start = even ? length - 3 : length - 2;
133 for (int i = start; i >= 0; i--) {
134 permutation[i] = index % (length - i);
135 sum += permutation[i];
136 index /= length - i;
137 for (int j = i + 1; j < length; j++)
138 if (permutation[j] >= permutation[i]) permutation[j]++;
139 }
140 if (even && sum % 2 != 0) {
141 swap(permutation, length - 1, length - 2);
142 }
143 }
144
145 // flip
146 public static int flipToIdx(int[] flip, int length, boolean zeroSum) {

Callers 15

edgemv2Method · 0.95
getEdgeMethod · 0.95
initMethod · 0.95
scrambleL2LMethod · 0.95
GearClass · 0.95
HalfTurnClass · 0.95
RouxMUClass · 0.95
scrambleMethod · 0.95
getmvMethod · 0.95
easyCrossMethod · 0.95
CubeRUClass · 0.95
scrambleMethod · 0.95

Calls 1

swapMethod · 0.95

Tested by

no test coverage detected