upBottomToDownFront method

Cube upBottomToDownFront(
  1. int index
)

Implementation

Cube upBottomToDownFront(int index) {
  final ep = List.filled(Edge.count, Edge.bottomRight);
  final edge = [Edge.upBottom, Edge.downRight, Edge.downFront];

  var b = index % 6; // Permutation
  var a = index ~/ 6; // Combination

  // generate permutation from index b
  for (var j = 1; j < 3; j++) {
    var k = b % (j + 1);
    b ~/= j + 1;

    while (k-- > 0) {
      _rotateRight(edge, 0, j);
    }
  }

  var x = 2;

  // generate combination and set edges
  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);
    }
  }

  return Cube._(cp: _cp, co: _co, ep: ep, eo: _eo);
}