upRightToDownFront method
Cube
upRightToDownFront(
- int index
)
Implementation
Cube upRightToDownFront(int index) {
final ep = List.filled(Edge.count, Edge.bottomRight);
final edge = [
Edge.upRight, Edge.upFront, //
Edge.upLeft, Edge.upBottom, //
Edge.downRight, Edge.downFront, //
];
final otherEdge = [
Edge.downLeft, Edge.downBottom, //
Edge.frontRight, Edge.frontLeft, //
Edge.bottomLeft, Edge.bottomRight, //
];
var b = index % 720; // Permutation
var a = index ~/ 720; // Combination
var k = 0;
// generate permutation from index b
for (var j = 1; j < 6; j++) {
k = b % (j + 1);
b ~/= j + 1;
while (k-- > 0) {
_rotateRight(edge, 0, j);
}
}
// generate combination and set slice edges
var x = 5;
for (var j = Edge.bottomRight.index; j >= 0; j--) {
if (a - _cnk(j, x + 1) >= 0) {
ep[j] = edge[x];
a -= _cnk(j, x-- + 1);
}
}
x = 0;
// set the remaining edges UR..DB
for (var j = Edge.upRight.index; j <= Edge.bottomRight.index; j++) {
if (ep[j] == Edge.bottomRight) {
ep[j] = otherEdge[x++];
}
}
return Cube._(cp: _cp, co: _co, ep: ep, eo: _eo);
}