computeUpRightFrontToDownLeftFront method

int computeUpRightFrontToDownLeftFront()

Implementation

int computeUpRightFrontToDownLeftFront() {
  final corner = List.filled(6, Corner.upRightFront);
  var a = 0, x = 0, b = 0;

  // compute the index a < (8 choose 6) and the permutation array.
  for (var j = Corner.upRightFront.index; j <= Corner.downRightBottom.index; j++) {
    if (_cp[j].index <= Corner.downLeftFront.index) {
      a += _cnk(j, x + 1);
      corner[x++] = _cp[j];
    }
  }

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

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

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

  return 720 * a + b;
}