Hi Tesla, I appreciate your comments, and I am aware that some of the stuff I write here can be difficult to get your head around, and I do try to keep things as simple as the context of the discussion will allow, some things you just have to hope the reader has come across before, otherwise one would end up writing War and Peace if starting at the very beginning every time. The question of "what is a lex value ?" has been asked before, most recently on a thread headed
Lexographic 101 in the
International & State Lotteries forum. Part way into that thread I gave this reply, which I have edited and expanded on:-
We are trying to give a number to each combination in an orderly logical fashion starting from 1-2-3-4-5-6 =Lex 1.
Well in the same way that a car odometer keeps track of your mileage, you have to have a counting system to understand a readout. We happen normally to use the decimal system, which means that when we increment by one, the rightmost digit of the odometer increases by one. However, when we get to the highest allowable value (9) on the last digit and want to increment by one ... the rule says that the last digit goes to zero and then second right digit goes up by one. This rule applies digit by digit working from the right.
We wish to create a combination sequence list for a particular lottery. So what about a lottery with 49 balls and there are 6 drawn balls ? Each combination starting from 1,2,3,4,5,6 right up to 44,45,46,47,48,49 can be represented by a Combination Sequence number instead. Its easy to do the first and the last numbers 1,2,3,4,5,6 = CSN 1 and 44,45,46,47,48,49 =CSN 13,983,816. Most people exchange the term
CSV for
Lex and vice versa.
Unlike the car odometer, where any value can sit in any position, sorted lottery results have upper and lower limits on a ball value in a position. The rule N6 has to be greater than N5, and N5 has to be greater than N4, etc working right to left must apply.
The Lex value for. 1- 2- 3- 4 - 5-
49 happens to be 44 (as demonstrated below) but how do we get the next sequence which has a Lex of 45?
The rules for indexing are similar to the odometer except when the rightmost figure gets to its highest allowable value for its position when sorted ascending then :-
First, the digit to its left is incremented by one (except when it has reached its highest allowable value for its position when sorted ascending - in which case it freezes there) and the rule carries on working right to left. In our example 5 becomes 6.
The rightmost digit reverts to its lowest allowable value for its position when sorted ascending - which is one more than the ball value to its left. In our example 49 reverts to 6+1 =7.
so we get 1 - 2 - 3- 4-
6- 7 has a Lex of 45.
Obviously the highest allowable values in each position are: 44-45-46-47-48-49.
Here are the first 94 CSV values and the combinations they represent. Note carefully what happens when the 6th digit reaches its upper limit ...
CSV..Combination or Lex value
01..... 1 2 3 4 5 6
02 ..... 1 2 3 4 5 7
03..... 1 2 3 4 5 8
04 ..... 1 2 3 4 5 9
05..... 1 2 3 4 5 10
06..... 1 2 3 4 5 11
07..... 1 2 3 4 5 12
08..... 1 2 3 4 5 13
09..... 1 2 3 4 5 14
10..... 1 2 3 4 5 15
11..... 1 2 3 4 5 16
12..... 1 2 3 4 5 17
13..... 1 2 3 4 5 18
14..... 1 2 3 4 5 19
15..... 1 2 3 4 5 20
16..... 1 2 3 4 5 21
17..... 1 2 3 4 5 22
18..... 1 2 3 4 5 23
19..... 1 2 3 4 5 24
20..... 1 2 3 4 5 25
21..... 1 2 3 4 5 26
22..... 1 2 3 4 5 27
23..... 1 2 3 4 5 28
24..... 1 2 3 4 5 29
25..... 1 2 3 4 5 30
26..... 1 2 3 4 5 31
27..... 1 2 3 4 5 32
28..... 1 2 3 4 5 33
29..... 1 2 3 4 5 34
30..... 1 2 3 4 5 35
31..... 1 2 3 4 5 36
32..... 1 2 3 4 5 37
33..... 1 2 3 4 5 38
34..... 1 2 3 4 5 39
35..... 1 2 3 4 5 40
36..... 1 2 3 4 5 41
37..... 1 2 3 4 5 42
38..... 1 2 3 4 5 43
39..... 1 2 3 4 5 44
40..... 1 2 3 4 5 45
41..... 1 2 3 4 5 46
42..... 1 2 3 4 5 47
43..... 1 2 3 4 5 48
44..... 1 2 3 4 5
49
45..... 1 2 3 4
6 7
46..... 1 2 3 4 6 8
47..... 1 2 3 4 6 9
48..... 1 2 3 4 6 10
49..... 1 2 3 4 6 11
50..... 1 2 3 4 6 12
51..... 1 2 3 4 6 13
52..... 1 2 3 4 6 14
53..... 1 2 3 4 6 15
54..... 1 2 3 4 6 16
55..... 1 2 3 4 6 17
56..... 1 2 3 4 6 18
57..... 1 2 3 4 6 19
58..... 1 2 3 4 6 20
59..... 1 2 3 4 6 21
60..... 1 2 3 4 6 22
61..... 1 2 3 4 6 23
62..... 1 2 3 4 6 24
63..... 1 2 3 4 6 25
64..... 1 2 3 4 6 26
65..... 1 2 3 4 6 27
66..... 1 2 3 4 6 28
67..... 1 2 3 4 6 29
68..... 1 2 3 4 6 30
69..... 1 2 3 4 6 31
70..... 1 2 3 4 6 32
71..... 1 2 3 4 6 33
72..... 1 2 3 4 6 34
73..... 1 2 3 4 6 35
74..... 1 2 3 4 6 36
75..... 1 2 3 4 6 37
76..... 1 2 3 4 6 38
77..... 1 2 3 4 6 39
78..... 1 2 3 4 6 40
79..... 1 2 3 4 6 41
80..... 1 2 3 4 6 42
81..... 1 2 3 4 6 43
82..... 1 2 3 4 6 44
83..... 1 2 3 4 6 45
84..... 1 2 3 4 6 46
85..... 1 2 3 4 6 47
86..... 1 2 3 4 6 48
87..... 1 2 3 4 6
49
88..... 1 2 3 4
7 8
89..... 1 2 3 4 7 9
90..... 1 2 3 4 7 10
91..... 1 2 3 4 7 11
92..... 1 2 3 4 7 12
93..... 1 2 3 4 7 13
94..... 1 2 3 4 7 14
Eventually at the very top of the Lex range, the last 3 values are:-
13,983,814..... 43 44 46 47 48 49
13,983,815..... 43 45 46 47 48 49
13,983,816..... 44 45 46 47 48 49
If you now read the thread I mentioned
http://www.lottoforums.com/lottery/international-state-lotteries/13552-lexicographic-101-a.html
there is more detail and discussions about how computers use these rules to calculate lex and vice versa
.