computeUpRightToUpLeft method

int computeUpRightToUpLeft()

Implementation

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

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

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

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

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

  return 6 * a + b;
}