P
Paul Black
Hi,
I found this Code the Other Day and thought I would give it a go.
Unfortunately, after it had Run, it Produced No Information at All (
Just a Blank Screen ). I also Tried Running it with "num = 14" (
Without the Quotes ) and Still got Nothing.
I Wonder if Anyone can Help Please.
All the Best
Paul
Message 2 in thread
From: Tom Ogilvy
Subject: Re: Coverage of a list of Lotto tickets
View this article only
Newsgroups: microsoft.public.excel.programming
Date: 2001-02-03 09:11:32 PST
Here is a brute force approach that took about 13 minutes on a Celeron
300
This didn't write the combinations, but could easily be adpated to do
that
(of course then you are talking a major increase in time).
Sub GenNumbers()
Dim start As Double
start = Timer
Dim lngCount(0 To 6) As Long
varray = Array(1, 2, 5, 6, 7, 9)
Dim r As Long
num = 49
For i = 1 To num - 5
For j = i + 1 To num - 4
For k = j + 1 To num - 3
For l = k + 1 To num - 2
For m = l + 1 To num - 1
For n = m + 1 To num
r = r + 1
If True Then
icnt = 0
For s = 0 To 5
If i = varray(s) Then icnt = icnt + 1
If j = varray(s) Then icnt = icnt + 1
If k = varray(s) Then icnt = icnt + 1
If l = varray(s) Then icnt = icnt + 1
If m = varray(s) Then icnt = icnt + 1
If n = varray(s) Then icnt = icnt + 1
Next
lngCount(icnt) = lngCount(icnt) + 1
End If
Next
Next
Next
Next
Next
Next
Debug.Print r
lngsum = 0
For s = 0 To 6
If s >= 3 Then lngsum = lngsum + lngCount(s)
Debug.Print s & " Matches: " & lngCount(s)
Next
Debug.Print "At least 3 matches " & lngsum
Debug.Print (Timer - start) / 60 & " minutes"
End Sub
Produced
13983816
0 Matches: 6096454
1 Matches: 5775588
2 Matches: 1851150
3 Matches: 246820
4 Matches: 13545
5 Matches: 258
6 Matches: 1
At least 3 matches 260624
12.3773151041667 minutes
Regards,
Tom Ogilvy
I found this Code the Other Day and thought I would give it a go.
Unfortunately, after it had Run, it Produced No Information at All (
Just a Blank Screen ). I also Tried Running it with "num = 14" (
Without the Quotes ) and Still got Nothing.
I Wonder if Anyone can Help Please.
All the Best
Paul
Message 2 in thread
From: Tom Ogilvy
Subject: Re: Coverage of a list of Lotto tickets
View this article only
Newsgroups: microsoft.public.excel.programming
Date: 2001-02-03 09:11:32 PST
Here is a brute force approach that took about 13 minutes on a Celeron
300
This didn't write the combinations, but could easily be adpated to do
that
(of course then you are talking a major increase in time).
Sub GenNumbers()
Dim start As Double
start = Timer
Dim lngCount(0 To 6) As Long
varray = Array(1, 2, 5, 6, 7, 9)
Dim r As Long
num = 49
For i = 1 To num - 5
For j = i + 1 To num - 4
For k = j + 1 To num - 3
For l = k + 1 To num - 2
For m = l + 1 To num - 1
For n = m + 1 To num
r = r + 1
If True Then
icnt = 0
For s = 0 To 5
If i = varray(s) Then icnt = icnt + 1
If j = varray(s) Then icnt = icnt + 1
If k = varray(s) Then icnt = icnt + 1
If l = varray(s) Then icnt = icnt + 1
If m = varray(s) Then icnt = icnt + 1
If n = varray(s) Then icnt = icnt + 1
Next
lngCount(icnt) = lngCount(icnt) + 1
End If
Next
Next
Next
Next
Next
Next
Debug.Print r
lngsum = 0
For s = 0 To 6
If s >= 3 Then lngsum = lngsum + lngCount(s)
Debug.Print s & " Matches: " & lngCount(s)
Next
Debug.Print "At least 3 matches " & lngsum
Debug.Print (Timer - start) / 60 & " minutes"
End Sub
Produced
13983816
0 Matches: 6096454
1 Matches: 5775588
2 Matches: 1851150
3 Matches: 246820
4 Matches: 13545
5 Matches: 258
6 Matches: 1
At least 3 matches 260624
12.3773151041667 minutes
Regards,
Tom Ogilvy