computeFrontRightToBottomRight method

int computeFrontRightToBottomRight()

Implementation

int computeFrontRightToBottomRight() {
  final edge = List.filled(4, Edge.upRight);
  var a = 0, x = 0, b = 0;

  // compute the index a < (12 choose 4) and the permutation array.
  for (var j = Edge.bottomRight.index; j >= Edge.upRight.index; j--) {
    if (Edge.frontRight.index <= _ep[j].index && _ep[j].index <= Edge.bottomRight.index) {
      a += _cnk(11 - j, x + 1);
      edge[3 - x++] = _ep[j];
    }
  }

  // compute the index b < 4! for the permutation.
  for (var j = 3; j > 0; j--) {
    var k = 0;

    while (edge[j].index != j + 8) {
      _rotateLeft(edge, 0, j);
      k++;
    }

    b = (j + 1) * b + k;
  }

  return 24 * a + b;
}