Free Touch Pricker
    Preparing search index...

    Function rankFromRow

    • Computes the rank of a Row.

      The numbering starts at 0 (rounds) and runs to n! - 1 (back rounds). Numbering is in "reverse colex order" (Knuth 7.2.1.2); i.e. if we reflect each row from right to left they would be in reverse lexicographic order.

        0: 123456
        1: 213456
        2: 132456
        3: 312456
      ...
      717: 645321
      718: 564321
      719: 654321
      
      > rankFromRow([2, 1, 4, 3], Pricker.Stage.Minimus));
      7
      > rankFromRow([6, 5, 4, 3, 2, 1], Pricker.Stage.Minor));
      719

      The rank is computed by counting the number of "inversions" to the left of each position (the left inversion count, l). The vector of counts is then interpreted as a single number using the Factorial number system.

                  ┌───┬───┬───┬───┐
      row: │ 2143
      ├───┼───┼───┼───┤
      inversions: │ - │ 101
      └───┴───┴───┴───┘

      rank = (1 × 1) + (0 × 2) + (1 × 6) = 7

      This scheme has been chosen for compatibility with the data tables that are produced by Philip Saddleton's "StedTurn" software.

      Parameters

      Returns number