JADELottery's Blog

JADELottery's Premium Blog: https://blogs.lotterypost.com/jadelottery

Combination Index, VB

Back on 2003-10-04 I posted a reply that helped find an Index position within a list of ascending order combinations.

As an example in a Pick 6 of 49 Numbers lottery, the first (Index of 1) combination would be (1, 2, 3, 4, 5, 6) and the last (Index of 13,983,816) combination would be (44, 45, 46, 47, 48, 49).

The original reply is linked here -> Lottery Combo Question.

We’ve reworked this a little bit, but would like to post the original here for reference.

Also, now that we have learned C/C++, we have converted it to that language.

 

Here's the Visual Basic algorithm I've come up with for finding the combinatorial index of a combination for N items taken R at a time.

Those of you who know VB, know what to do.

Those of you who know another programming language and VB should know what to do.

 

Global Counter(1 To R) As Integer

 

  'R must be assigned some value before program run.

  'The program can handle anything R or less when when assigned.

  'note: This global array must be put in the declarations part of the function module or some other module.

 

 

Function Fact(N) As Double

 

  'The factorial function, Fact(N)= N!

  'This is a recursive calling function, means it calls itself multiple times.

  'If your BASIC language dose not support recursive calling, then this function needs to be changed to meet the function of:

  'N! = N * (N - 1) * (N - 2) * (N - 3) * ... * 3 * 2 * 1, where 0! = 1 and N < 0 is undefined.

 

  If (N < 1) Then

    Fact = 1

  Else

    Fact = N * Fact(N - 1)

  End If

 

End Function

 

Function Perm(N, R) As Double

 

  'This is the permutational function of N items taken R at a time.

 

  If (N < R) Then

    Perm = 0

  Else

    Perm = Fact(N) / Fact(N - R)

  End If

 

End Function

 

Function Comb(N, R) As Double

 

  'This is the combinatorial function of N items taken R at a time.

 

  If (N < R) Then

    Comb = 0

  Else

    Comb = Perm(N, R) / Fact(R)

  End If

 

End Function

 

Function Cdist(N, R, C, Z) As Double

 

  'This is the column distribution function of N items taken R at a time in column C for item Z.

 

  If (Z < C) Or (Z > (N - R + C)) Or (Z > N) Or (C > R) Or (N < 1) Or (R < 1) Or (C < 1) Or (Z < 1) Then

    Cdist = 0

  Else

    Cdist = Comb(Z - 1, C - 1) * Comb(N - Z, R - C)

  End If

 

End Function

 

Function fColumnSum(N, R, Z) As Double

 

  'This function performs a column count for N items taken R at a time for item Z.

 

  If Z < 1 Then

    fColumnSum = 0

  ElseIf (Z >= 1) And (Z < N - R + 1) Then

    col_sum = 0

    For a = 1 To Z

      col_sum = col_sum + Cdist(N, R, 1, a)

    Next a

    fColumnSum = col_sum

  ElseIf Z >= N - R + 1 Then

    fColumnSum = Comb(N, R)

  End If

 

End Function

 

Function Comb_Count(N, R) As Double

 

  'This is the combinatorial index for a combination in N items taken R at a time and R must not be larger than the Counter() array size R.

  'Counter() is an array containing the combination.

  'The Counter() array must be globally dimensioned outside the function and must be the size of R.

  'Also, numbers (item index) must be assigned in ascending order; Counter(1)is the minimum number through Counter(R) is the maximum number.

 

  fsum = fColumnSum(N, R, Counter(1) - 1) + 1

  For a = 2 To R

    fsum = fsum + fColumnSum(N - Counter(a - 1), R - a + 1, Counter(a) - Counter(a - 1) - 1)

  Next a

  Comb_Count = fsum

 

End Function

 

After putting the functions in the appropriate module and putting the Counter array in the declarations section of the main program module, all that needs to be done is assign the combination to the Counter array and call the Comb_Count function.

It would look something like this: (i.e. for a 6/49 lottery with a combination of (06, 10, 17, 37, 40, 49))

 

Sub Some_subroutine_of_the_main_program()

 

  Counter(1) = 6

  Counter(2) = 10

  Counter(3) = 17

  Counter(4) = 37

  Counter(5) = 40

  Counter(6) = 49

  CombinIndex = Comb_Count(49, 6)

 

    'CombinIndex now contains the combinatorial index of that combination.

 

End Sub

 

The combinatorial index of (06, 10, 17, 37, 40, 49) in 49 numbers taken 6 at a time is 7,275,389.

How you want to assign the combination values is up to you.

The way I shown here is just an example.

Also, this only works with single combinations like a 6/49 or 5/35.

Powerball or Mega Millions are not single combos.

They are a multiple combos, a pick 5 part and a pick 1 part.

This algorithm only works on the pick 5 part or the pick 1 part.

You may need to text format some of the code here, however, it will work.

Entry #421

I am ME

Vince Lombardi had a saying about TEAM and I, however there's more to that saying you were not made aware of.

The modified version is as follows:

 

There's no I in TEAM, however, you can't make the TEAM without ME.

 

 

 

Think about it for a bit.

Entry #418

The New Quantum Selection Algorithm test program is available

The new algorithm test was so successful that I'm going to release the test program by itself.

Provide any feedback, however, since this is a test, the program will be unsupported and not upgraded.

It is a functional part of the new JADE Lottery System Generator Analyzer (JADE LSG 2.0).

Yes, there will be tweaking of the algorithm, but that will be released in JADE LSGA.

You can get the test program at the following links.

ZIP File Link
  http://home.mchsi.com/~jadelottery/Downloads/JADELotterySelectorTest.ZIP

Self Extrating ZIP File EXE Link
  http://home.mchsi.com/~jadelottery/Downloads/JADELotterySelectorTest.EXE

As always, this is freeware.

There is also a Topic started about this test in the Lottery Systems Forum, linked below.

The New Quantum Selection Algorithm test is available for testing

The ZIP files also have an alternate version for those that might have problems with the regular program.

Entry #415

New Algorithm note

You might be thinking this is just some plain old wille-nille random generator.

Trust me, IT IS NOT.

It's a Structured Random Selection or better known as a Quantum Selection.

Entry #414

Pick 20 of 99 Numbers for 100 Plays

Example of a Pick 20 of 99 Numbers for 100 Plays.

Index -  01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
00001 -  08 15 24 29 32 33 35 36 38 53 55 57 61 65 70 73 84 93 97 98
00002 -  03 10 14 17 20 34 46 52 64 67 74 75 76 78 86 87 88 89 90 96
00003 -  04 06 07 09 13 18 21 23 39 41 49 56 62 63 71 81 85 92 95 99
00004 -  16 19 22 25 26 28 30 42 43 45 48 58 59 60 68 69 77 82 83 91
00005 -  01 02 05 11 12 27 31 37 40 44 47 50 51 54 66 72 79 80 91 94
00006 -  02 13 21 22 25 27 30 33 37 41 52 65 74 75 76 78 84 88 96 98
00007 -  03 10 12 20 28 29 31 40 45 55 57 61 63 82 86 87 94 95 97 99
00008 -  01 04 11 15 17 19 23 35 36 44 46 51 53 54 64 68 72 79 89 92
00009 -  06 07 14 18 26 38 39 42 47 48 49 50 58 60 66 67 73 80 83 90
00010 -  05 08 09 13 16 24 32 34 43 56 59 62 69 70 71 77 78 81 85 93
00011 -  05 07 16 27 38 39 41 42 44 48 50 52 54 61 70 79 88 91 95 99
00012 -  10 15 17 18 21 22 32 33 36 53 55 58 63 64 66 74 77 82 86 97
00013 -  01 04 06 14 19 24 28 29 40 59 60 62 65 67 68 71 76 81 84 96
00014 -  02 08 09 11 30 31 34 35 37 45 46 47 72 75 80 83 87 89 92 93
00015 -  03 05 12 20 23 25 26 27 41 43 49 51 56 57 69 73 85 90 94 98
00016 -  06 08 09 10 12 15 31 34 37 38 49 51 53 55 60 61 87 89 93 98
00017 -  02 14 18 26 29 30 33 42 54 57 58 65 67 72 80 81 84 86 90 95
00018 -  04 17 19 21 22 32 35 36 43 44 46 50 52 59 69 76 85 88 91 97
00019 -  03 13 16 20 23 24 39 45 56 62 64 66 70 71 74 75 77 82 92 94
00020 -  01 02 07 11 25 28 40 47 48 58 63 68 73 76 78 79 83 91 96 99
00021 -  08 11 14 16 18 20 30 39 46 48 56 68 69 82 86 88 92 95 96 97
00022 -  01 15 23 26 35 36 38 40 42 44 45 50 53 60 63 67 77 81 89 90
00023 -  03 04 09 10 17 22 24 25 41 43 47 51 52 59 70 74 84 85 87 98
00024 -  05 19 21 27 28 29 37 49 61 62 64 65 66 71 73 78 79 80 94 99
00025 -  06 07 12 13 27 31 32 33 34 46 51 54 55 57 63 72 75 83 84 93
00026 -  01 14 28 30 35 36 38 41 43 45 47 52 69 72 73 78 79 81 82 88
00027 -  07 08 11 15 18 21 22 25 29 34 44 49 55 62 68 70 80 85 90 93
00028 -  03 04 05 06 23 24 26 39 40 42 48 57 65 66 75 76 83 94 96 98
00029 -  02 09 10 13 17 31 50 56 58 60 64 67 74 77 86 87 89 91 97 99
00030 -  12 16 18 19 20 32 33 34 37 40 50 53 54 59 60 61 71 81 92 95
00031 -  02 06 07 08 10 11 16 24 29 30 32 36 38 57 65 78 79 82 90 95
00032 -  05 09 15 27 33 37 44 46 48 53 64 66 68 71 72 75 76 80 92 98
00033 -  04 28 31 43 45 51 52 56 58 61 62 63 69 70 77 86 88 91 96 99
00034 -  03 12 17 20 22 23 39 41 42 49 55 67 74 83 84 85 87 89 93 97
00035 -  01 08 11 12 13 14 19 20 21 22 25 26 35 47 51 54 59 73 92 94
00036 -  02 06 14 18 24 26 30 35 47 48 54 56 60 66 74 81 82 83 87 98
00037 -  19 31 33 38 39 44 53 55 61 63 68 69 73 78 85 90 91 93 95 99
00038 -  05 07 09 13 15 23 25 32 37 43 45 46 57 59 62 67 70 71 94 96
00039 -  01 03 04 10 16 17 28 29 34 36 41 52 65 75 79 80 84 88 89 97
00040 -  04 05 21 27 40 42 49 50 52 53 58 64 72 73 76 77 84 86 97 99
00041 -  02 06 10 16 21 22 23 30 34 35 36 37 43 47 56 57 59 91 93 95
00042 -  13 14 15 24 25 26 27 39 46 49 51 55 65 66 69 77 81 82 83 87
00043 -  01 09 18 19 28 32 42 45 68 70 71 78 79 80 85 86 89 92 96 98
00044 -  07 11 17 20 29 33 40 41 44 54 58 60 61 62 72 74 75 76 90 94
00045 -  01 03 08 12 13 26 27 31 38 41 47 48 50 56 61 63 64 67 88 98
00046 -  04 07 14 15 20 22 30 38 39 43 45 55 60 75 84 85 88 90 96 97
00047 -  02 06 11 12 16 29 31 33 35 37 48 54 67 68 69 72 78 79 91 94
00048 -  03 09 32 34 36 44 57 59 62 64 65 70 74 77 82 83 86 89 92 95
00049 -  05 10 17 18 21 23 24 28 42 46 49 50 51 58 63 66 80 87 93 99
00050 -  07 08 13 19 25 36 37 40 44 52 53 59 60 71 73 76 81 90 91 94
00051 -  03 08 14 16 21 23 24 35 53 64 68 71 72 73 75 83 85 87 95 96
00052 -  01 02 06 10 11 17 27 28 30 34 45 55 58 62 63 66 74 77 79 97
00053 -  18 19 22 25 29 32 33 39 40 41 43 49 50 52 57 61 69 70 80 82
00054 -  04 05 15 20 38 42 46 47 48 51 54 65 67 76 81 88 89 92 93 98
00055 -  06 08 09 12 15 23 26 31 46 56 61 64 71 74 78 79 84 86 91 99
00056 -  09 12 14 20 26 27 30 31 32 52 53 60 63 68 70 72 82 85 88 96
00057 -  10 17 18 24 35 36 41 42 54 57 65 67 76 78 81 86 89 90 92 95
00058 -  01 03 04 05 11 16 19 21 28 34 39 43 45 49 50 51 83 84 93 94
00059 -  13 29 33 38 40 47 48 55 56 58 59 69 73 75 77 80 87 97 98 99
00060 -  02 05 07 13 22 24 25 26 37 42 44 58 62 66 71 79 80 96 98 99
00061 -  04 06 09 16 23 29 32 46 50 52 54 57 60 62 72 81 88 90 93 95
00062 -  03 11 15 17 19 21 22 27 35 36 37 45 47 49 59 64 68 73 76 78
00063 -  07 14 18 20 25 33 34 41 44 51 53 66 67 77 82 83 87 89 92 94
00064 -  01 08 10 12 30 31 38 39 40 48 56 61 63 65 69 70 74 84 85 86
00065 -  02 24 25 28 36 39 40 41 43 55 59 68 69 72 75 78 83 88 91 97
00066 -  02 12 13 20 22 30 34 38 42 43 49 50 53 65 75 76 79 82 87 92
00067 -  10 11 16 17 18 19 32 35 44 46 47 51 54 55 63 84 86 93 96 98
00068 -  03 05 08 09 14 15 21 26 28 33 37 52 60 62 66 71 73 81 85 99
00069 -  01 07 23 27 31 48 56 58 61 64 67 70 74 77 80 89 90 94 95 97
00070 -  01 02 04 06 15 16 19 20 23 24 25 29 33 45 57 60 71 79 81 91
00071 -  09 12 21 27 32 44 45 46 50 55 56 61 62 63 70 76 82 93 95 98
00072 -  06 10 30 34 37 38 40 42 43 48 51 53 59 65 86 88 90 92 94 97
00073 -  08 11 13 17 22 47 54 64 66 67 69 72 74 75 84 85 87 91 96 99
00074 -  03 04 07 14 18 29 31 35 39 41 49 52 57 58 68 73 78 80 83 89
00075 -  01 02 05 10 11 13 15 16 21 26 28 31 34 36 41 42 51 66 77 81
00076 -  04 06 12 25 32 38 45 53 59 64 65 67 74 75 84 85 91 92 93 98
00077 -  03 09 14 18 19 24 36 52 55 56 57 61 62 68 76 80 83 86 87 90
00078 -  17 20 28 29 30 37 43 44 48 50 58 60 63 69 73 78 82 88 95 96
00079 -  05 07 08 22 23 26 33 35 39 40 46 47 49 54 71 72 77 89 94 97
00080 -  01 05 06 07 18 27 40 46 50 65 68 70 76 78 79 81 82 85 92 99
00081 -  10 13 17 21 23 28 31 34 44 47 53 55 60 62 77 83 86 91 95 96
00082 -  04 11 14 15 24 27 32 35 38 52 56 57 66 72 74 75 79 93 97 98
00083 -  02 08 16 25 30 33 39 42 43 51 58 59 61 69 70 73 87 89 90 94
00084 -  03 12 19 20 22 26 29 36 37 41 45 48 49 63 64 67 71 80 84 99
00085 -  06 09 20 32 35 37 39 42 43 45 51 53 54 59 62 67 70 84 85 88
00086 -  01 07 09 15 23 26 29 33 38 40 41 57 65 69 71 86 90 93 96 98
00087 -  03 05 14 18 21 22 24 27 31 47 50 60 72 73 75 76 78 88 95 97
00088 -  04 10 16 17 25 30 36 54 56 58 61 66 68 79 80 82 83 89 92 99
00089 -  02 08 11 12 13 19 28 34 44 46 48 49 52 55 64 74 81 87 91 94
00090 -  01 03 07 10 16 19 26 53 56 61 62 63 66 69 70 77 82 84 97 99
00091 -  08 12 17 20 30 38 39 49 51 52 59 64 67 71 74 78 80 91 94 95
00092 -  04 05 06 13 24 25 31 36 40 46 47 48 54 55 68 72 73 77 81 88
00093 -  09 11 14 15 21 23 29 33 35 41 45 50 63 76 83 87 89 90 92 96
00094 -  02 18 22 28 32 34 37 42 43 44 57 58 60 65 75 79 85 86 93 98
00095 -  06 09 16 19 27 34 36 39 58 60 68 70 71 79 82 88 92 95 96 98
00096 -  02 03 15 18 20 24 25 31 40 42 51 65 72 73 81 83 85 89 97 99
00097 -  04 07 08 12 13 14 17 29 30 32 33 43 48 55 62 66 75 77 78 84
00098 -  11 23 26 27 28 41 46 47 52 54 56 61 63 69 74 76 87 91 93 94
00099 -  01 05 10 21 22 35 37 38 44 45 49 50 53 57 59 64 67 80 86 90
00100 -  05 07 12 14 19 21 25 26 28 33 41 45 65 68 72 81 82 87 88 94

Entry #413

Sample Powerball Pick 5 of 59 Numbers.

I'm having problems posting a reply in the other post.

So, I'll create a new one.

Tried the Powerball Pick 5 of 59 Numbers.

Below is a sample selection for 100 Plays.

00001 -  11 17 27 32 50
00002 -  09 12 24 39 59
00003 -  19 41 42 49 58
00004 -  08 14 25 34 55
00005 -  01 03 06 38 52
00006 -  10 21 37 53 54
00007 -  23 28 36 44 56
00008 -  02 07 13 20 31
00009 -  16 18 33 46 51
00010 -  04 05 30 45 48
00011 -  15 35 40 47 57
00012 -  22 26 27 29 43
00013 -  07 17 20 33 42
00014 -  10 14 15 30 31
00015 -  04 11 16 19 28
00016 -  22 23 24 25 46
00017 -  01 09 21 35 57
00018 -  03 12 32 45 50
00019 -  05 36 41 43 53
00020 -  18 40 49 55 56
00021 -  06 08 13 37 48
00022 -  26 44 47 51 52
00023 -  34 39 54 58 59
00024 -  02 03 29 32 38
00025 -  14 20 22 35 52
00026 -  18 19 28 31 57
00027 -  02 11 16 34 38
00028 -  09 21 43 54 59
00029 -  04 10 47 51 55
00030 -  05 36 44 49 53
00031 -  01 06 30 50 58
00032 -  07 17 24 27 33
00033 -  25 40 42 48 56
00034 -  13 29 39 45 46
00035 -  08 15 23 37 41
00036 -  12 13 26 29 50
00037 -  06 22 34 39 49
00038 -  02 14 27 32 35
00039 -  03 04 31 40 55
00040 -  05 37 45 53 56
00041 -  30 38 42 44 52
00042 -  10 12 25 36 47
00043 -  01 11 17 43 48
00044 -  15 16 26 33 41
00045 -  08 21 46 51 57
00046 -  07 09 20 23 24
00047 -  18 19 28 54 59
00048 -  08 23 32 48 58
00049 -  29 37 43 50 55
00050 -  17 27 30 41 42
00051 -  12 13 31 35 52
00052 -  26 34 40 44 59
00053 -  11 16 49 53 58
00054 -  02 03 09 39 56
00055 -  10 24 36 38 45
00056 -  01 04 15 28 57
00057 -  07 22 25 46 47
00058 -  05 06 18 21 33
00059 -  14 19 20 51 54
00060 -  40 41 45 56 59
00061 -  04 23 24 28 39
00062 -  11 12 26 46 58
00063 -  01 05 29 30 44
00064 -  08 15 25 43 57
00065 -  03 32 33 35 42
00066 -  13 22 31 34 54
00067 -  09 10 19 38 50
00068 -  06 21 27 52 53
00069 -  17 18 20 37 55
00070 -  02 07 36 48 49
00071 -  14 16 47 51 59
00072 -  09 15 17 32 40
00073 -  02 08 10 18 55
00074 -  13 27 39 49 50
00075 -  06 20 31 35 52
00076 -  05 14 24 34 54
00077 -  25 26 33 47 53
00078 -  11 42 44 46 56
00079 -  07 23 30 38 51
00080 -  03 19 21 29 48
00081 -  04 22 37 43 45
00082 -  16 28 36 57 58
00083 -  01 12 14 29 41
00084 -  02 04 11 23 50
00085 -  01 13 33 39 58
00086 -  03 12 24 30 35
00087 -  08 19 20 52 56
00088 -  06 10 15 21 22
00089 -  09 27 34 47 59
00090 -  05 17 25 26 36
00091 -  28 44 48 49 53
00092 -  16 38 46 54 57
00093 -  07 40 41 42 51
00094 -  31 32 37 43 45
00095 -  02 14 15 18 55
00096 -  22 31 33 38 58
00097 -  01 11 13 21 50
00098 -  03 04 06 09 37
00099 -  19 29 42 46 47
00100 -  10 23 30 39 59

Entry #412

New Wheel Algorithm

I came up with an incredible, simple wheel generating algorithm.

It is so simple and amazing.

Why didn't I see it before?

Damn!!!

It also compresses the wheel to an absolute minimum size.

It took me a while, but I got it.

Went the long way around, but I GOT IT.

Cool

Entry #410

The George Carlin Effect

Speaking in Great Carlin Ease...

Ok folks, now that the vote is over and the leaders are elected.

Time to hold everyone accountable.

Even though I voted Obama, I will not be feeling that Warm and Fuzzy, OK.

Nope, I'm Cold and Pricky as always.

I want to see some serious shet going on there in DC, from all parties, Republican, Democrat, and any party that happens to blow your skirt up.

Everyone needs to hold these MF'ers feet to the flame and don't let up.

We need action and we need it now!

Entry #408

Pick 3 Quantum Matrix 50 Predictions

We'll try to post every day for every state's Pick 3 in the Lottery Post Prediction Board.

Just check out the Predictions Board for your state.

Also, check the Results page for a possible match.

Or, check out the 'See Yesterday's Winners' page in the 'Predictions' menu.

Look for a possible match for your state there.

Entry #407

The Old JADE LSG Program

BobP had requested this one.

Back for a limited time.

Below are the links to the old JADE Lottery System Generator program.

Get it while you can.

It won't be there for very long.

ZIP File Link - http://home.mchsi.com/~jadelottery/Downloads/JADE_Lottery_Setup_Old_Program.ZIP

Self Extracting ZIP File EXE Link - http://home.mchsi.com/~jadelottery/Downloads/JADE_Lottery_Setup_Old_Program.EXE

The files will unzip to a folder named 'JADE Lottery Setup Alt'.

Run the Setup.exe in that folder to setup the program.

Those of you who may have the program might want to get this one.

I was working on a slight modification that was never released in the original.

It's a Multiple Rebuild option that was a Idea I had to optimize generating a system.

Read the Help file on Getting Started.

Entry #406