Home

 
Combination Ordinal Numbers

A combination of numbers can be represented by literally listing the numbers, e.g. (1,2,3,4,6) or (1,2,3,4,5). An alternative way is to tell the combination's ordinal number in the list of all combinations of its size. E.g. the two combinations above are number 2 and number 1 respectively. The (6,8,9,10,11) and (7,8,9,10,11) are numbers 461 and 462, since they are the last two out of 5 from 11 and there are 462 of them all. For those in between, there is more than one way of how they can be ordered. Usually, the following two systems are used:

a) relative ordering (the usual lexicographic order)

b) absolute ordering (also called "combination sequence numbers" or CSN)

To compare them, see how 4 of 7 are listed in each case:

RELATIVE

1.   1,2,3,4
2.   1,2,3,5
3.   1,2,3,6
4.   1,2,3,7
5.   1,2,4,5
6.   1,2,4,6
etc.

ABSOLUTE

1.   1,2,3,4
2.   1,2,3,5
3.   1,2,4,5
4.   1,3,4,5
5.   2,3,4,5
6.   1,2,3,6
etc.

Obviously, the relative ordinal numbers depend on the pool size (7 in this case). If the pool were bigger than 7, the combination number 5 would be (1,2,3,8) rather than (1,2,4,5). This is not the case with absolute ordinals, where all combinations of e.g. 5 numbers are listed before number 6 is added. Or not added, if pool is 5. Makes no difference for combinations before. So an absolute ordinal number and the pick (4 here) alone uniquely determine the combination.

There are two separate cases in program Ininuga when ordinal numbers are calculated.
a) A separate "Convert Ordinals" dialog box can be opened to convert an individual combination. This box is intended to be used manually as a utility calculator for this purpose. (Within Ininuga's pool range 1..32; else see the link below.)
b) Ordinal numbers are also an option while displaying, exporting or importing the wheels.

To see the source code of the routines, used for this purpose, open:

Pascal & Assembler:  the optimized working version. (Compare comments in assembler with Pascal only version below.)

Pascal only:  included for documentation purpose, although working, but slower.

- - -

Link: To calculate relative ordinals (pool 30 and above) go to Martin Round's page

- - -

And here is an observation for anyone interested in calculating these numbers. There is a simple conversion between absolute and relative ordinals. Let's take combinations 4 from 9 for example.
E.g., Abs.Ord.(2,3,5,7) = 22
Replace this with (9+1-2, 9+1-3, 9+1-5, 9+1-7) = (8,7,5,3)
Rel.Ord.(3,5,7,8) = 105
which is 126+1-22, with 126 being the total of 4 from 9.
(BTW: All those "+1" turn into "-1" in case of zero-based indexing.)


Top | Home | What are wheels | About Ininuga | Links | Free download | Ordinal numbers | Code tips