Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Coverage Calculation Speed in VBA, VB, C# and C++

344 views
Skip to first unread message

fair...@bigpond.com

unread,
May 1, 2009, 5:28:19 AM5/1/09
to
Just a further update on trying to get to John Rawson's sub "photon"
speed; "photon" speed in the forseeable future I will leave as a wish.
What I'm looking for is a sub 1 sec time for the test below in a
Windows environment ie forms, buttons, text boxes and grids etc

The basic test is to calculate the coverage of say 44 45 46 47 48 49
by iterating through all the 13,983,816 possiblities and counting a
match Three. The combination should then be flagged as covered in an
array or whatever so it will not be counted for the next combination
to calculate. The algorithm you use should give an accurate count
whatever the combination entered ie 260624

My slow Computer Estimate Faster Computer

VBA 31 min 20 min
(Access or Excel)

VB 2008 68 sec 44 sec

C# 52 sec 34 sec

C++ 12 sec 8 sec

Chances are in VBA you will find your first attempt will take over an
hour. I've used VBA mainly in Access for years and only when this
"pedal to metal" or "foot to floor" processing is required as in
coverage calculation has speed become an issue. I use VB 2008 more now
than Access and this difference in speed means I will be using it even
more.

Colin Fairbrother
www.lottoposter.com

peteros

unread,
May 1, 2009, 6:22:13 AM5/1/09
to

I think that it's more depends on which algorithm used, than what
language.
Send me your email adress and I'll send you a small program for you to
test on your computer, to get a more accurate test. It takes about 7.6
seconds on my (slow) laptop, measured with acutimer from "lovepimples
data compression page"

Written in pascal many years ago, Checking algorithm greatly improved
and provided by Uros Boltin, author of Ininuga.

fair...@bigpond.com

unread,
May 1, 2009, 8:36:01 AM5/1/09
to
Peterros

If you do happen to click on profile or visit my website www.lottoposter.com
to get my email address then please don't send me someone else's
intellectual property which you have undertaken to illegally
distribute. Why you think I would be interested in something showing
no significant difference to my C++ code's time defies my
comprehension.

Further on comprehension I don't understand how you can say there is
no difference between the languages speed when the post amply
illustrated that with VBA taking at least half hour more. The
algorithm I used is basically the same in all the four languages
allowing for syntax differences.

As for testing accuracy I've been testing for more than 30 years and
don't need to be told how to suck eggs.

There's plenty of rubbish posts made in this newsgroup that you can
practice answering.. I suggest you curb your desire to answer a
serious post with a bunch of waffle that basically says more about who
you are and your lack of comprehension than add something
constructive. You may also find it a good idea to check out the author
before adopting a condescending attitude.

Colin Fairbrother

Gerry

unread,
May 1, 2009, 12:14:28 PM5/1/09
to

<fair...@bigpond.com> wrote in message
news:550a9e40-93ac-4612...@r31g2000prh.googlegroups.com...

> Peterros
>
> If you do happen to click on profile or visit my website www.lottoposter.com
> to get my email address then please don't send me someone else's
> intellectual property which you have undertaken to illegally
> distribute. Why you think I would be interested in something showing
> no significant difference to my C++ code's time defies my
> comprehension.
>
> Further on comprehension I don't understand how you can say there is
> no difference between the languages speed when the post amply
> illustrated that with VBA taking at least half hour more. The
> algorithm I used is basically the same in all the four languages
> allowing for syntax differences.
>
> As for testing accuracy I've been testing for more than 30 years and
> don't need to be told how to suck eggs.

You've been sucking eggs for 30 years ?


Paracelsus

unread,
May 1, 2009, 1:04:10 PM5/1/09
to

"Gerry" <tul...@earthlink.net> wrote in message
news:2MGdnf6HZOd-gmbU...@earthlink.com...

Must be pickled eggs, judging by the sour puss.

Honest John

unread,
May 1, 2009, 1:33:27 PM5/1/09
to

Crikey Colin, that's a bit heavy. I'm sure Peter only intended well.

John

peteros

unread,
May 1, 2009, 2:09:34 PM5/1/09
to
On 1 Maj, 14:36, fairb...@bigpond.com wrote:
> Peterros
>
> If you do happen to click on profile or visit my websitewww.lottoposter.com
> to get my email address then please don't send me someone else's
> intellectual property which you have undertaken to illegally
> distribute. Why you think I would be interested in something showing
> no significant difference to my C++ code's time defies my
> comprehension.

The one and only reason for me to made you the offer to test it on the
SAME machine as your other testings, if you don't understand the value
of testing under EQUAL situations, that's up to you. I did make a test
on my faster computer and the result is ( 10 times and each time the
time was about the same within a few milliseconds ) 4.3 seconds,
whitch is almost 3times faster than your C++.

So the conclusion should be that PASCAL is faster than C++ then ?????
since your oppinion on this is THAT EVERY COMPUTER IS ABOUT THE SAME
SPEED ????


>
> Further on comprehension I don't understand how you can say there is
> no difference between the languages speed when the post amply
> illustrated that with VBA taking at least half hour more. The
> algorithm I used is basically the same in all the four languages
> allowing for syntax differences.

Sure but find a FASTER algorithm in any language might speed the
program up quite a bit. So a totally different approach on ANY
language might give an edge. What you have shown is the LANGUAGE
DIFFERENCES on some code that might be either well written or clumsy
written.


>
> As for testing accuracy I've been testing for more than 30 years and
> don't need to be told how to suck eggs.
>
> There's plenty of rubbish posts made in this newsgroup that you can
> practice answering.. I suggest you curb your desire to answer a
> serious post with a bunch of waffle that basically says more about who
> you are and your lack of comprehension than add something
> constructive. You may also find it a good idea to check out the author
> before adopting a condescending attitude.

I have no idea what you are trying to say so I leave it for here,
seems like you have as bitchy attitude as my dog.

/Pr
>
> Colin Fairbrother

fair...@bigpond.com

unread,
May 1, 2009, 8:44:01 PM5/1/09
to
Peteros

I stand by what I wrote. No doubt my reply was a bit more forceful
than the namby pamby banter you usually get. Before writing the reply
I had a quick look at your contributions in this newsgroup and decided
you needed a bit of a reality check as to how others may view your
"advice".

Firstly, I am interested in code that makes a substantial difference,
Reading the original post you will see the stated objective was to get
the lag time below 1 sec as in John Rawson's CoverMaster. If you had
offered to send me code you had written or gave a link to a website
where the code was available then that is perfectly acceptable and
warmly welcomed. People distributing someone elses intellectual
property as if their own I find reprenhensible; assuming that another
is willing to receive it is an insult.

In your reply I once again have to raise your powers of comprehension
and logic. I gave two sets of figures which to a normal person would
indicate I am acknowledging that the same code with a faster processor
will give a lower time. That you could draw a conclusion I am stating
each computer has the same speed reinforces my assessment of your
cognitive deficiencies.

Peteros wrote: "I have no idea what you are trying to say so I leave
it for here."
I agree with this line. I suggest you have a look at the original post
where I raised the speed issue and was even quoted by Bob Perkis. In
that I stated the under 1 second speed of Coverage calculation as in
the test in C++ by John Rawson was down more to his algorithm than to
the language. This I illustrated by running my algorithm in four
languages with VBA giving a very slow result, VB 8 and C# close and C+
+ noticeably better - hence the suck eggs expression.

The main intent of my post was to make any potential Coverage
calculating person aware that you will have to go beyond Access and
Excel using VBA to get a reasonable time. Some years ago I would have
found this extremely useful information if I had seen it somewhere and
my computer would have had less hard disk hard usage not to mention
the long processing times. The other possibility was that someone
might offer some pseudo code as to how they go about getting a sub-
second time. I do have some further ideas; for particular blocks I can
get the calculation right in under 1 second - the trick I think may be
in doing some select or switch depending on the block so the lower
time calculation code is always applied.

For those reading this post and new to newsgroups it's best to
understand that in an unmonitored environment like this you are going
to get the usual variety of neighbourhood dogs yapping, barking or
going beserk as you walk by. Honest John's I will take as that similar
to a Great Dane - a short disapproving Wuff to let you know of its
presence and then a cock of the head to see your reaction and judge
your reply. The best thing you can do with some of the craziest muts
is to show no fear, walk as close as possible and look the other way.
Even dogs are offended by this.

Colin Fairbrother
www.lottoposter.com

Gerry

unread,
May 2, 2009, 11:14:50 AM5/2/09
to

<fair...@bigpond.com> wrote in message
news:550a9e40-93ac-4612...@r31g2000prh.googlegroups.com...

> Peterros


>
> If you do happen to click on profile or visit my website www.lottoposter.com
> to get my email address

Alexa ranks your website at #20,261,978. The odds of winning a 6/49 jackpot
are better than that.

Is that why you're always so cranky ?

http://alexa.com/


fair...@bigpond.com

unread,
May 2, 2009, 12:38:35 PM5/2/09
to
On May 3, 1:14 am, "Gerry" <tula...@earthlink.net> wrote:
> <fairb...@bigpond.com> wrote in message
>
> news:550a9e40-93ac-4612...@r31g2000prh.googlegroups.com...

> Alexa ranks your website at #20,261,978. The odds of winning a 6/49 jackpot


> are better than that.
>
> Is that why you're always so cranky ?
>
> http://alexa.com/

Gerry

My website exists for me to publish information on Lotto which is a
hobby interest of mine, I don't tell people how to win first prize in
the Lottery so that rules out the majority of people that are
interested in looking up Lotto on the web. I do tell people that using
the best of my methods they will get a marginal improvement over
Random Selections and that is not likely to impress most of the
remainder.

I have shown that the nonsense on Covers or Wheels espoused since the
1980's with repeat payable subsets decreases your chances of winning
and I like to think that the more sensible people that have visited my
site have found that useful information.

Mostly I use Lotto as a focus for doing programming and get
satisfaction out of overcoming the challenges I set myself in this
field and that is good for nourishing and envigorating ones brain. How
Alexa rates the site is of no great interest to me. As long as search
engines like Google give me a reasonable representation for some key
words then I'm happy.

I take a stand on issues that I think are important to me and promote
honesty. I respect copyright and think that others should to, I
dislike con-artists and those that try to pass themself off as having
some expertise in an area where they have little if any. I don't like
abuse in forums or user groups but it's par for the course when you
question the intelligence of some. Generally, I treat people as they
treat me but that doesn't mean I won't have a go at someone that I may
be familiar with in this field for now many years. You need a
reasonably thick skin to participate in groups like this. Mature
adults can argue vigorously and accept winning or losing a point or
two.

Generally, I have always run a course which stood above that of the
lowest common denominator. There are people in this world who have
respect for that.

Colin Fairbrother
www.lottoposter.com

Gerry

unread,
May 2, 2009, 1:49:31 PM5/2/09
to

<fair...@bigpond.com> wrote in message
news:85c6cda5-4edc-4bf9...@p6g2000pre.googlegroups.com...

Gerry

Colin Fairbrother
www.lottoposter.com
-----------------------------------------------

343 words of going on and on about yourself makes your dismissal
of Alexa's ranking unconvincing.


fair...@bigpond.com

unread,
May 2, 2009, 7:24:04 PM5/2/09
to
(Gerry: Your concern for the Alexa ranking of www.LottoPoster.com is
not one I share; simple as that.)

Revised timings for Coverage Calculation on a slow computer:

C++ 15 sec
C# 45 sec
VB 68 sec
VBA 31 min 8 sec

I came up with a new way of approaching it on my 8km walk yesterday
which may get me under the 1 sec mark for C++.

Colin Fairbrother


nigel

unread,
May 3, 2009, 8:29:24 AM5/3/09
to
fair...@bigpond.com wrote:

I think it's worth pointing out that benchmark timings not only depend
on what is running on the PC, but also what has been running. On my
number-crunching machine (Win 98), some progs run up to twice as quickly
depending on the order which previous programs have been loaded and
unloaded. My guess would be that Microshit are not terribly clever at
managing paged memory.

Rebooting the PC is no guarantee either, because on this PC (Win XP
Half) the startup items don't run in a consistent order, so icons on the
task bar (antivirus, firewall, internet connection etc) rarely have the
same order from one boot to the next.

Evil Nigel

fair...@bigpond.com

unread,
May 3, 2009, 9:03:43 AM5/3/09
to
On May 3, 10:29 pm, nigel <use...@nospam.com> wrote:

Nigel

For each of the languages I set a start and finish time variable then
get the difference and the processing is all done in RAM ie no writing
or reading from the hard disk. I used a factor of around .8 to get an
estimate of the faster processor times. The tests have been done
repeatedly with the computer quiet and are consistent.

I'm still looking for ideas - those that I have come up with have not
worked out. The routines mentioned by Peteros I had a look at years
ago ie Uros Boltin with his bit maps etc but not to my liking and
strangely limited to 32 integers which makes me dubious of Peteros's
test time for a 6/49 Lotto game.

Colin

Gerry

unread,
May 3, 2009, 11:08:34 AM5/3/09
to

<fair...@bigpond.com> wrote in message
news:00c05c22-3f69-43b8...@z23g2000prd.googlegroups.com...

> (Gerry: Your concern for the Alexa ranking of www.LottoPoster.com is
> not one I share; simple as that.)

Odd that someone with a big ego like yours would be unconcerned
about his irrelevance.

>
> Revised timings for Coverage Calculation on a slow computer:
>
> C++ 15 sec
> C# 45 sec
> VB 68 sec
> VBA 31 min 8 sec
>
> I came up with a new way of approaching it on my 8km walk yesterday
> which may get me under the 1 sec mark for C++.
>
> Colin Fairbrother
>
>

Conclusion:

Get C++ so you can lose at lotto faster.


Gerry

unread,
May 3, 2009, 11:17:30 AM5/3/09
to

"nigel" <use...@nospam.com> wrote in message
news:ILidnaeKT5a_E2DU...@posted.plusnet...

> fair...@bigpond.com wrote:
>
>> (Gerry: Your concern for the Alexa ranking of www.LottoPoster.com is
>> not one I share; simple as that.)
>>
>> Revised timings for Coverage Calculation on a slow computer:
>>
>> C++ 15 sec
>> C# 45 sec
>> VB 68 sec
>> VBA 31 min 8 sec
>>
>> I came up with a new way of approaching it on my 8km walk yesterday
>> which may get me under the 1 sec mark for C++.
>>
>> Colin Fairbrother
>
> I think it's worth pointing out that benchmark timings not only depend on what is
> running on the PC, but also what has been running. On my number-crunching machine (Win
> 98), some progs run up to twice as quickly depending on the order which previous
> programs have been loaded and unloaded. My guess would be that Microshit are not
> terribly clever at managing paged memory.
>
> Rebooting the PC is no guarantee either, because on this PC (Win XP Half)

Your're up to half an XP already?

Oh, I gettit, half XP, half braincell...

> the startup items don't run in a consistent order, so icons on the task bar (antivirus,
> firewall, internet connection etc) rarely have the same order from one boot to the next.

It's like herding cats

>
> Evil Nigel
>


nigel

unread,
May 3, 2009, 11:35:42 AM5/3/09
to
Gerry wrote:

> "nigel" <use...@nospam.com> wrote

>>Rebooting the PC is no guarantee either, because on this PC (Win XP Half)
>
> Your're up to half an XP already?
>

XP Home, pretentions of being a real operating system, but half the
functionality/useability is missing.

Evil Nigel

fair...@bigpond.com

unread,
May 3, 2009, 10:17:44 PM5/3/09
to
I have started a forum on this topic at my site:

http://lottoposter.com/forum_posts.asp?TID=593&PN=1

For this particular forum currently, guests can post. Being a
monitored site any unneccessary yapping can be eliminated and
droppings removed.

Colin Fairbrother

Michael

unread,
May 3, 2009, 11:53:44 PM5/3/09
to

<fair...@bigpond.com> wrote in message
news:209b6ae4-c449-4c23...@v1g2000prd.googlegroups.com...

3.7 sec VB6.0 win XP AMD Athlon
Should be much faster if compiled to exe but for some
reason my VB6 will no longer obey that with a c2.exe error

Private Sub Command1_Click()
Dim a As Long, b As Long, c As Long
Dim d As Long, e As Long, f As Long
Dim ct As Long, hits As Long, processed As Long


Dim theTicket(1 To 49) As Long

Dim t1 As Date, t2 As Date

t1 = Timer

theTicket(44) = 1: theTicket(45) = 1: theTicket(46) = 1
theTicket(47) = 1: theTicket(48) = 1: theTicket(49) = 1

For a = 1 To 44
For b = a + 1 To 45
For c = b + 1 To 46
For d = c + 1 To 47
For e = d + 1 To 48
For f = e + 1 To 49
idx = idx + 1
ct = 0
ct = theTicket(a) + theTicket(b) + theTicket(c) + _
theTicket(d) + theTicket(e) + theTicket(f)

If ct > 2 Then 'fit for processing

processed = processed + 1


End If

Next f, e, d, c, b, a


t2 = Timer

Print processed, (t2 - t1)

End Sub


fair...@bigpond.com

unread,
May 4, 2009, 12:39:01 AM5/4/09
to
On May 4, 1:53 pm, "Michael" <mikh...@bigpond.com> wrote:
> <fairb...@bigpond.com> wrote in message
> End Sub- Hide quoted text -
>
> - Show quoted text -

Michael

What can I say? Brilliant, elegant, concise and easy to understand. I
tried it using VBA and got 2.6 secs. Very humbling especially as I've
used the principles before but didn't make the connection.

This is the type of code I enjoy reading. You're up there with Ken
Getz in my admiration stakes. It certainly makes a mockery of the
complicated ways of going about it and those that like to mock the
itteration as naive.

Too bad there isn't a mini Nobel prize. You'd be a good candidate.

Kind regards
Colin Fairbrother

nigel

unread,
May 4, 2009, 6:39:26 AM5/4/09
to
My VB is a bit rusty, but are you sure you are using the optimum
datatype for a-f? In a similarish situation I used double-precision
because the variables eventually got splatted out to spreadsheet cells,
but if they're only being used as subscripts then something smaller
might be marginally quicker.

There's also a frig you can do to get the timings precision in
milliseconds, very handy if you want to time a few passes of a loop then
scale it up to 14 million or so.

Evil Nigel

fair...@bigpond.com

unread,
May 4, 2009, 8:18:42 AM5/4/09
to
Nigel

The usual mistake I've come across even with programmers who should
know better is to declare an array that has say, 13,983,616 elements
as long when if the values it holds is less than 256 then byte or
short is OK.

I have noticed Excel users declaring double variables for no good
reason when only integers are involved. I put it down to force of
habit dealing with cents or pennies. If it has not much effect on the
timing of the routine then it doesn't really matter.

With Michael' s code I will add an array or vector to flag the blocks
as covered or not which takes up a bit of memory, when I do the
timings for the other languages and there are a couple of minor
optimizations I will include which reduce the time for calculating
lower blocks. Definitely, we must now measure in micro seconds maybe
even nano.

I was in a state of shock when I made the last post so I read the
wrong figure - instead of 2.6 secs it should have been 6.52 sec down
from 31 mins for VBA. Let me just spell that out - FROM 1860 secs TO
6.52 secs or 285 times better in Excel or Access. I confidently
predict that the crown for King of Coverage Speed Calculation will
pass from John Rawson, Esquire to Michael Harrington, a fellow
Australian, photons or no photons.

An interesting ramification of this is that those who like to roll
their own and don't want to look further than Excel can now do all
their own calculations in respectable times. In other words you are
not restricted to a particular programs way of doing it.

Colin Fairbrother

Honest John

unread,
May 4, 2009, 8:33:30 AM5/4/09
to

You don't need to loop through every combo.

If :

theTicket(a) + theTicket(b) + theTicket(c)

= 3 then get on with the next c

In the case of 1,2,3,4,5,6 the saving will be considerable.

John

Honest John

unread,
May 4, 2009, 8:42:22 AM5/4/09
to
fair...@bigpond.com wrote:
> Nigel
>
> The usual mistake I've come across even with programmers who should
> know better is to declare an array that has say, 13,983,616 elements
> as long when if the values it holds is less than 256 then byte or
> short is OK.
>
> I have noticed Excel users declaring double variables for no good
> reason when only integers are involved. I put it down to force of
> habit dealing with cents or pennies. If it has not much effect on the
> timing of the routine then it doesn't really matter.
>
> With Michael' s code I will add an array or vector to flag the blocks
> as covered or not which takes up a bit of memory, when I do the
> timings for the other languages and there are a couple of minor
> optimizations I will include which reduce the time for calculating
> lower blocks. Definitely, we must now measure in micro seconds maybe
> even nano.
>
> I was in a state of shock when I made the last post so I read the
> wrong figure - instead of 2.6 secs it should have been 6.52 sec down
> from 31 mins for VBA. Let me just spell that out - FROM 1860 secs TO
> 6.52 secs or 285 times better in Excel or Access. I confidently
> predict that the crown for King of Coverage Speed Calculation will
> pass from John Rawson, Esquire to Michael Harrington, a fellow
> Australian, photons or no photons.

Give over :-)

CM checks the single 44,45,46,47,48,49 in a fraction of a second (about
0.2 seconds here). And that's using code to check any number of tickets.
With respect to Michael, the code he's given only checks one line, which
is what you asked for.

Modify it to check any wheel and see what you think of the speed. Then
you can modify your prediction :-)

John

Michael

unread,
May 4, 2009, 4:49:02 PM5/4/09
to

"nigel" <use...@nospam.com> wrote in message
news:-YOdnZoxqelGWGPU...@posted.plusnet...
Long integers are the preferred data type for iterations when
using VB6. Previous versions and indeed many other languages
would work better with something else. I think VB6 is unique in
this respect.

To get the timing in milliseconds would be a simple matter of
multiplying the time difference by 1000.
Cheers Mick.


Message has been deleted
Message has been deleted

fair...@bigpond.com

unread,
May 4, 2009, 11:30:56 PM5/4/09
to
John

Just stirrin' the possum. You're still the King of Coverage Speed
Calculation. It would be interesting to know in general terms how
you do it but I also understand how after spending many hundreds of
hours you don't feel inclined to give too much away - after all
your CoverMaster program is free! Anyway, your 0.2 secs reigns supreme
and the ability of your program to give about the same
time whether it be 1 or 100 lines is brilliant..

The two improvements in the first two loops for lower number blocks I
mentioned in my last post and I have included them in the code as they
were in the previous code. However, for those who like to do things
themself, like myself, we have Michael Harrington to thank for much
lower processing times.

My slow desktop computer is 2.4 Ghz and 480 MB of RAM.

Results for calculating the coverage of 1 block 44 45 46 47 48 49 for
Pool 49, Pick 6 ie 13,983,816 possibilities and a coverage of 260,624.

2.4 GHz est. 3 GHz

VBA 6.52 sec 5.22 sec
(Excel or Access)

VB 2008 0.44 sec 0.35 sec

C# 0.64 sec 0.51 sec

C++ 4.00 sec 3.20 sec


Why does C++ give such a relatively high time? I don't know - I'm only
a novice for that language. It could have something to do with a
13983816 Vector Boolean taking up a lot of contiguous memory. C# is
managed and the memory for its arrays does not have to be contiguous.
If someone else wants to give a time for the code in C++ go ahead -
just let us know how fast your processor is and how large the RAM.

The good news for me is I don't have to worry about all those curly
braces and missing the semicolons at the end of the line anymore.

VB rules! You can get a free copy of Visual Basic Express here:
http://www.microsoft.com/Express/VB/

I use Visual Studio Standard which includes VB, C# and C++ with
intellisense in the IDE. Study what you need and what you get before
forking out for the Professional edition.

Colin Fairbother
www.lottoposter.com

Robert Perkis

unread,
May 4, 2009, 11:55:24 PM5/4/09
to

> Colin Fairbrother
> www.lottoposter.com

2.4 gz isn't slow, but 480 megs of ram is slowing you down.
Under 768 megs of ram CoverMaster drops to writing memory
on disc over 100 lines with a large Pick-6 wheel say for 49
numbers. With 1000 megs it barely hiccups at the 100 line
mark. Memory is a lot cheaper then a new puter.

Robert Perkis / http://www.lotto-logix.com/memory.html

fair...@bigpond.com

unread,
May 5, 2009, 12:44:51 AM5/5/09
to
Robert

I know ... I know ...

I have a much faster laptop - but my teenage daughter commandeered
that - but come 4.00pm she gently inquires whether I'm going for my
8km walk - the seat is still warm before the door is closed and the
broadband music and messenger boards are going full pelt.

But my typing speed hasn't improved and I can still type faster with
one or two fingers rather than 10.

I'm used to the speed and can tell when something is running slower
than it should ...

I'm punishing myself for a reason I've forgotten ....

Life is too short to spend so much time in a virtual world staring at
a computer monitor ...

I guess the real reason is that when I bought it years ago I made sure
it had 2 internal hard drives so with a bit of pruning I've managed to
cram what I need in.

I know, I''ll wait until I get the $900 economic stimulus package that
the Australian Goverment is giving to everyone. Some of us think it is
stupid thing to do but we'll take the money anyway.

Colin Fairbrother
www.lottoposter.com

Michael

unread,
May 5, 2009, 4:03:21 AM5/5/09
to

"Honest John" <kestre...@ntlworld.com> wrote in message
news:EtudnbZabek...@giganews.com...

Using combinatorial notation nCr I notice that the 260624 is made up of

43C0 * 6C6 = 1
43C1 * 6C5 = 258
43C2 * 6C4 = 13545
43C3 * 6C3 = 246820

Could this hold the secret of not having to cycle through
the entire 13983816?

Cheers Mick.


Michael

unread,
May 5, 2009, 4:54:36 AM5/5/09
to

"Michael" <mik...@bigpond.com> wrote in message
news:dpSLl.8693$y61...@news-server.bigpond.net.au...
31 millisecs for this

Private Sub Command1_Click()
'line 44,45,46,47,48,49


Dim a As Long, b As Long, c As Long
Dim d As Long, e As Long, f As Long

Dim ct As Long


Dim t1 As Date, t2 As Date

t1 = Timer


For a = 44 To 44 '...43C0 * 6C6


For b = a + 1 To 45
For c = b + 1 To 46
For d = c + 1 To 47
For e = d + 1 To 48
For f = e + 1 To 49

Debug.Print a, b, c, d, e, f
ct = ct + 1

Next f, e, d, c, b, a

For a = 1 To 43 '...43C1 * 6C5
For b = 44 To 45


For c = b + 1 To 46
For d = c + 1 To 47
For e = d + 1 To 48
For f = e + 1 To 49

'Debug.Print a, b, c, d, e, f
'Process this lot
ct = ct + 1

Next f, e, d, c, b, a

For a = 1 To 42 '...43C2 * 6C4
For b = a + 1 To 43

For c = 44 To 46


For d = c + 1 To 47
For e = d + 1 To 48
For f = e + 1 To 49

'Debug.Print a, b, c, d, e, f
'Process this lot
ct = ct + 1

Next f, e, d, c, b, a

For a = 1 To 41 '...43C3 * 6C3
For b = a + 1 To 42
For c = b + 1 To 43

For d = 44 To 47


For e = d + 1 To 48
For f = e + 1 To 49

'Debug.Print a, b, c, d, e, f
'Process this lot
ct = ct + 1

Next f, e, d, c, b, a

t2 = Timer


Print ct, (t2 - t1) * 1000; " millisecs"
End Sub


Message has been deleted
Message has been deleted
Message has been deleted

fair...@bigpond.com

unread,
May 5, 2009, 11:01:06 AM5/5/09
to
On May 5, 6:54 pm, "Michael" <mikh...@bigpond.com> wrote:
> "Michael" <mikh...@bigpond.com> wrote in message
>
> news:dpSLl.8693$y61...@news-server.bigpond.net.au...
>
>
>
>
>
> > "Honest John" <kestrel.su...@ntlworld.com> wrote in message
> >news:EtudnbZabek...@giganews.com...
> >> Michael wrote:
> >>> <fairb...@bigpond.com> wrote in message
> End Sub- Hide quoted text -
>
> - Show quoted text -

Michael

I believe you've done it; the Crown is yours. My deep admiration and
respect for your work. In Visual Basic, which I've worked with for
years, I did not think the calculation times you have achieved were
possible. I am now in a position to throw a test to C++ scorners that
should leave them speechless.

I have tested the code by replacing the Pool integers with P to P - 7
and for a Pool size from 7 to 99 and the calculations done were
correct. Here is the truly amazing bit - on my computer setting the
Pool to 99 and the block to 94 95 96 97 98 99 your code gives the
Coverage of 2,660,049 in less than 1 second. Using the same parameters
in Covermaster the calculation takes on my computer about 26 seconds.
Unbelievable but true!

I see no reason why there would be a problem with calculating multiple
blocks.


This is a great day for those that like to create their own Coverage
calculation programs. To the best of my knowledge this code has never
been published before and so the algorithm should from now on be known
as the Harrington coverage algorithm. For those who have difficulty
remembering names just think of the song H - A - R - R - I - N - G - T
- O - N that's him.

Best regards
Colin Fairbrother

Honest John

unread,
May 5, 2009, 2:13:57 PM5/5/09
to
fair...@bigpond.com wrote:
> On May 5, 6:54 pm, "Michael" <mikh...@bigpond.com> wrote:
>> "Michael" <mikh...@bigpond.com> wrote in message
>>
>> news:dpSLl.8693$y61...@news-server.bigpond.net.au...
>>
>>
>>
>>
>>
>>> "Honest John" <kestrel.su...@ntlworld.com> wrote in message
>>> news:EtudnbZabek...@giganews.com...
>>>> Michael wrote:
>>>>> <fairb...@bigpond.com> wrote in message
>> End Sub- Hide quoted text -
>>
>> - Show quoted text -
>
> Michael
>
> I believe you've done it; the Crown is yours. My deep admiration and

Sorry, Crown stays here for now.

All the code does is tell you the combinations that one (hard coded)
ticket covers. It just cycles through the combinations covered by the
one ticket : 44,45,46,47,48,49

For starters, make it work for any given ticket.

Don't get me wrong, I'm not being disrespectful, you're just a long way
off a testing routine of any practical use.

John

Michael

unread,
May 5, 2009, 5:24:37 PM5/5/09
to
John, this should work for any given single ticket now.
Admittedly the output will often not be in perfect order
but so far there is no performance drag.

Private Sub Command1_Click()
Dim a As Long, b As Long, c As Long
Dim d As Long, e As Long, f As Long

Dim ct As Long


Dim t1 As Date, t2 As Date

Dim Holder(1 To 49) As Long, temp As Long
Dim startno As Long
Dim TheLine(1 To 6) As Long

'test 7,11,15,36,38,48

t1 = Timer
'>>>>>>>>>>>>> Add Code to Cater for any Line >>>>>>>>>>>>>>>>>>>>>>

TheLine(1) = 7: TheLine(2) = 11: TheLine(3) = 15
TheLine(4) = 36: TheLine(5) = 38: TheLine(6) = 48

startno = 44

For a = 1 To 49 'initialize Holder Array
Holder(a) = a
Next a

'We now want to swap the Line numbers to the
'end of the array so that our original code still works

For a = 1 To 6
temp = TheLine(a)
Holder(temp) = Holder(startno) 'swapping
Holder(startno) = temp
startno = startno + 1
Next a


'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

For a = 44 To 44 '43C0 * 6C6


For b = a + 1 To 45
For c = b + 1 To 46
For d = c + 1 To 47
For e = d + 1 To 48
For f = e + 1 To 49

'Debug.Print Holder(a), Holder(b), _
'Holder(c), Holder(d), Holder(e), Holder(f)


'Process this lot
ct = ct + 1

Next f, e, d, c, b, a

For a = 1 To 43 '43C1 * 6C5


For b = 44 To 45
For c = b + 1 To 46
For d = c + 1 To 47
For e = d + 1 To 48
For f = e + 1 To 49

'Debug.Print Holder(a), Holder(b), _
'Holder(c), Holder(d), Holder(e), Holder(f)


'Process this lot
ct = ct + 1

Next f, e, d, c, b, a

For a = 1 To 42 '43C2 * 6C4


For b = a + 1 To 43

For c = 44 To 46
For d = c + 1 To 47
For e = d + 1 To 48
For f = e + 1 To 49

'Debug.Print Holder(a), Holder(b), _
'Holder(c), Holder(d), Holder(e), Holder(f)


'Process this lot
ct = ct + 1

Next f, e, d, c, b, a

For a = 1 To 41 '43C3 * 6C3


For b = a + 1 To 42
For c = b + 1 To 43

For d = 44 To 47
For e = d + 1 To 48
For f = e + 1 To 49

'Debug.Print Holder(a), Holder(b), _
'Holder(c), Holder(d), Holder(e), Holder(f)

Message has been deleted

Michael

unread,
May 5, 2009, 8:26:30 PM5/5/09
to
Code getting a bit long winded now. Without thorough testing
it can (should) now handle any single line and sort the output.
300 millisecs now. The sort caused it grow exponentially

Private Sub Command1_Click()
Dim a As Long, b As Long, c As Long
Dim d As Long, e As Long, f As Long

Dim ct As Long, i As Long


Dim t1 As Date, t2 As Date
Dim Holder(1 To 49) As Long, temp As Long

Dim AllNos(1 To 49) As Boolean ' To aide in sorting

'test 7,11,15,36,38,48

startno = 44


'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Erase AllNos 'prepare to sort output
AllNos(Holder(a)) = True
AllNos(Holder(b)) = True
AllNos(Holder(c)) = True
AllNos(Holder(d)) = True
AllNos(Holder(e)) = True
AllNos(Holder(f)) = True

For i = 1 To 49
'If AllNos(i) = True Then Debug.Print i
'Process this lot
Next i

ct = ct + 1

Next f, e, d, c, b, a

For a = 1 To 43 '43C1 * 6C5
For b = 44 To 45
For c = b + 1 To 46
For d = c + 1 To 47
For e = d + 1 To 48
For f = e + 1 To 49

Erase AllNos 'prepare to sort output

AllNos(Holder(a)) = True
AllNos(Holder(b)) = True
AllNos(Holder(c)) = True
AllNos(Holder(d)) = True
AllNos(Holder(e)) = True
AllNos(Holder(f)) = True

For i = 1 To 49
'If AllNos(i) = True Then Debug.Print i
'Process this lot
Next i

ct = ct + 1

Next f, e, d, c, b, a

For a = 1 To 42 '43C2 * 6C4
For b = a + 1 To 43

For c = 44 To 46
For d = c + 1 To 47
For e = d + 1 To 48
For f = e + 1 To 49

Erase AllNos 'prepare to sort output

AllNos(Holder(a)) = True
AllNos(Holder(b)) = True
AllNos(Holder(c)) = True
AllNos(Holder(d)) = True
AllNos(Holder(e)) = True
AllNos(Holder(f)) = True

For i = 1 To 49
'If AllNos(i) = True Then Debug.Print i
'Process this lot
Next i


ct = ct + 1

Next f, e, d, c, b, a

For a = 1 To 41 '43C3 * 6C3
For b = a + 1 To 42
For c = b + 1 To 43

For d = 44 To 47
For e = d + 1 To 48
For f = e + 1 To 49

Erase AllNos 'prepare to sort output

AllNos(Holder(a)) = True
AllNos(Holder(b)) = True
AllNos(Holder(c)) = True
AllNos(Holder(d)) = True
AllNos(Holder(e)) = True
AllNos(Holder(f)) = True

For i = 1 To 49
'If AllNos(i) = True Then Debug.Print i
'Process this lot
Next i

Michael

unread,
May 5, 2009, 8:29:37 PM5/5/09
to

<fair...@bigpond.com> wrote in message
news:25210b4d-51a7-4f56...@y33g2000prg.googlegroups.com...

Michael

Best regards
Colin Fairbrother

Does this mean Mike from Mars in no longer code guru
in chief around here?
Cheers Mick.


fair...@bigpond.com

unread,
May 5, 2009, 8:44:06 PM5/5/09
to
Michael

The guy you refer to is fighting his demons so I won't comment. I do
notice that cross breed between a chihuahua ,a skinny sausage dog and
a Lewis look-alike has retired to its humpy for a while.

What we sane people in this troubled world have to put up with. Messy
dogs and sour pusses!

Best of luck
Colin

Message has been deleted

fair...@bigpond.com

unread,
May 5, 2009, 9:04:16 PM5/5/09
to
John

Come off it!

What do you think this line means: -


"I have tested the code by replacing the Pool integers with P to P - 7
and for a Pool size from 7 to 99 and the calculations done were
correct."

It means where Michael had 49 I put the variable P, where it was 48 I
put P -1, where it was 47 I put P -2 etc. Then in the form I already
had set up I increased the range for a combo from 7 to 99. So, to test
any pool I selected the Pool from a drop down, the pick I left at 6
and then entered the block in either a grid or text boxes. I then
clicked on a button which brought up Michael's latest routine - I have
buttons for other routines. The output giving the coverage and time
taken is shown in both a label and the debug window.

John, what you said can't be interpreted in any other way than sour
grapes. For any one with any real coding ability given Michael's
algorithm the rest is a piece of cake. I already have internal
programs that do just about everything that your Covermaster does
including your Wheel Analyzer. The big problem was the time it took to
calculate. I could give it a kick start in say a 6/49 Lotto by simply
entering the first 8 lines with distinct integers. Micheal's algorithm
doesn't extend what I was already doing - it just enables it to be
done in fantastically less time.

The object of this thread was not to come up with a completely fleshed
out program. What do I have to do to get you to acknowledge Michael
has won - produce a program that mimics everything CoverMaster does?
I don't want to do that because I don't believe in producing
distorted, repeat subset Covers. That is why you've never seen me
publish one of them even though I may have a few that beat the
misguided bounds. For the Covers I do produce with no repeat payable
subsets, using all integers and Coverage maximized on the main winning
number Michael's algorithm is an invaluable time saver. I have also
illustrated that if you take the number of lines from the first line
in my Covers they beat the distorted Covers for the same nunber of
lines every time. http://lottoposter.com/forum_posts.asp?TID=583

Colin Fairbrother
http://lottoposter.com/forum_topics.asp?FID=90


Honest John

unread,
May 6, 2009, 2:23:49 AM5/6/09
to
fair...@bigpond.com wrote:
> John
>
> Come off it!
>
> What do you think this line means: -
> "I have tested the code by replacing the Pool integers with P to P - 7
> and for a Pool size from 7 to 99 and the calculations done were
> correct."
>
> It means where Michael had 49 I put the variable P, where it was 48 I
> put P -1, where it was 47 I put P -2 etc. Then in the form I already
> had set up I increased the range for a combo from 7 to 99. So, to test
> any pool I selected the Pool from a drop down, the pick I left at 6
> and then entered the block in either a grid or text boxes. I then
> clicked on a button which brought up Michael's latest routine - I have
> buttons for other routines. The output giving the coverage and time
> taken is shown in both a label and the debug window.
>
> John, what you said can't be interpreted in any other way than sour
> grapes.

Now who's being silly ? I gave him the inspiration in the first place !

> For any one with any real coding ability given Michael's
> algorithm the rest is a piece of cake. I already have internal
> programs that do just about everything that your Covermaster does
> including your Wheel Analyzer. The big problem was the time it took to
> calculate. I could give it a kick start in say a 6/49 Lotto by simply
> entering the first 8 lines with distinct integers. Micheal's algorithm
> doesn't extend what I was already doing - it just enables it to be
> done in fantastically less time.
>
> The object of this thread was not to come up with a completely fleshed
> out program.

But you're getting orgasmic over a simple piece of code that spits out
the numbers covered by one ticket. With respect, again, to Michael, it's
hardly a wheel tester.

> What do I have to do to get you to acknowledge Michael
> has won - produce a program that mimics everything CoverMaster does?

Test a 6/49 wheel, any wheel and count the uncovered cominations. That's
a pretty basic requirement of any tester.

I'll pass the Crown over when you can test any wheel faster than CM.

Then I'll go away and do it even faster. :-)

Honest John

unread,
May 6, 2009, 2:35:40 AM5/6/09
to
Michael wrote:
> John, this should work for any given single ticket now.
> Admittedly the output will often not be in perfect order
> but so far there is no performance drag.
>
> Private Sub Command1_Click()
> Dim a As Long, b As Long, c As Long
> Dim d As Long, e As Long, f As Long
> Dim ct As Long
> Dim t1 As Date, t2 As Date
> Dim Holder(1 To 49) As Long, temp As Long
> Dim startno As Long
> Dim TheLine(1 To 6) As Long
>
> 'test 7,11,15,36,38,48
>
> t1 = Timer
> '>>>>>>>>>>>>> Add Code to Cater for any Line >>>>>>>>>>>>>>>>>>>>>>
>
> TheLine(1) = 7: TheLine(2) = 11: TheLine(3) = 15
> TheLine(4) = 36: TheLine(5) = 38: TheLine(6) = 48
>
> startno = 44
>
> For a = 1 To 49 'initialize Holder Array
> Holder(a) = a
> Next a
>
> 'We now want to swap the Line numbers to the
> 'end of the array so that our original code still works
>

Ok, transpose it to the line you want :-)

Let's push on a little, let's have two 6 lines. Input by the user...

John

Michael

unread,
May 6, 2009, 5:05:51 AM5/6/09
to

"Honest John" <kestre...@ntlworld.com> wrote in message
news:tMqdnU0qzOd...@giganews.com...

Ok give me 2 weeks or so. I'll generate say 100 random lines
and give the precise percentage of the 49C6 that have at least
3 covered. Is it required that the specific uncovered/covered
are sent to output? Or is the % breakdown good enough?
Will post the code here for others to use as they see fit.

Cheers Mick.


Honest John

unread,
May 6, 2009, 9:50:16 AM5/6/09
to

CM ignores the output after a certain amount, can't remember the
default, think it's 25, but that can be specified in the max entries box
on the uncovered combos form.

Good luck !

John

Gerry

unread,
May 6, 2009, 10:08:52 AM5/6/09
to

"Honest John" <kestre...@ntlworld.com> wrote in message
news:6tmdnVZceep...@giganews.com...

Yowser !!

Do that and there will be a case of Kestrel Super in your inbox :-)


Message has been deleted

Honest John

unread,
May 7, 2009, 2:24:06 AM5/7/09
to
fair...@bigpond.com wrote:

> On May 6, 4:23 pm, Honest John <kestrel.su...@ntlworld.com> wrote:
>
> " I'll pass the Crown over when you can test any wheel faster than CM.
>
> Then I'll go away and do it even faster. :-)- "
>
> John
>
> I have constructed a simplified version of my Windows LTW with
> coverage calculation and just need to add Michaels code and some code
> to read the items from the grid. You can see a screenshot here:
> http://lottoposter.com/forum_posts.asp?TID=594&PID=1103#1103
> Before doing so I thought I'd float something by you for your
> consideration.
>
> Now, from your quoted statement above I can see some problems arising
> where your finished product is knocked unnecessarily. Just try
> generating one line for Pool 99 from either the Generate or
> Tools>Search>Best Play and after 15 minutes or so you get 1 2 3 4 5 6.
> I don't need to tell you that the first 16 lines with the best
> coverage are Unique 1's and this can be calculated in a nano-second.
>

I agree, the first few lines are always trivial and I could certainly
code that in but it's a little pointless.

> My offered solution is this. Let's have three Crowns. The first Crown
> goes to Micheal for the under 1 second published Coverage Calculation
> code.

I'll submit my entry for that here :

10 print 260624

Or given the parameters, you could make a few calls to come nCr routine,
certainly no need for any iterations.

> The second Crown goes to you for the best Windows Cover/Wheel
> generator with repeat subsets allowed - you have no real opposition so
> there should be no dissension. The third Crown goes to me for
> producing sets with no repeat subsets and once again there is no
> competition and I don't mind if it is made of aluminium foil as long
> as the 1000 diamonds are genuine. (We need a sponsor for that.)
> However, in all three categories new contenders cannot be ruled out.
> (Pesky creatures.)

Have you published these lines anywhere ?
>
> I also have to admit to telling a fib on the timings; I did have it
> very close to Michaels first contribution but I thought if I put that
> up it would not draw the response I wanted. (It has been a very
> successful thread!) The magic elixir that I knew existed was out of my
> expertise and more in the realm of maths and computer science wizards;
> it was the code that Michael subsequently posted. The hint you made
> may have assisted him; the hint I made that there were ways beyond
> naive iteration may have had an effect also. So when I got "orgasmic
> over a simple piece of code" as you put it, the intention was to goad
> you or someone else with the knowledge to top Michael's first code.
>
> I think Michael surprised you, me and probably quite a few others with
> how quick he came up with the right code which is definitely not to be
> trivialized. Others may have known about it but Michael presumably
> thought it out himself and put it in the public domain. All credit and
> future acknowledgement should go to him. You may notice that I was the
> only one who thanked him. Let me make it clear that any future program
> involving Coverage calculation will be thought of as including
> Michael's code whether it is acknowledged or not.
>
> Regards
> Colin Fairbrother
> www.lottoposter.com
>
>
>

fair...@bigpond.com

unread,
May 7, 2009, 2:46:52 AM5/7/09
to
On May 6, 4:23 pm, Honest John <kestrel.su...@ntlworld.com> wrote:

" I'll pass the Crown over when you can test any wheel faster than
CM.


Then I'll go away and do it even faster. :-)- "


John


I have constructed a simplified version of my Windows LTW with
coverage calculation and just need to add Michaels code and some code
to read the items from the grid. You can see a screenshot here:
http://lottoposter.com/forum_posts.asp?TID=594&PID=1103#1103
Before doing so I thought I'd float something by you for your
consideration.


Now, from your quoted statement above I can see some problems arising
where your finished product is knocked unnecessarily. Just try
generating one line for Pool 99 from either the Generate or
Tools>Search>Best Play and after 15 minutes or so you get 1 2 3 4 5 6.
I don't need to tell you that the first 16 lines with the best
coverage are Unique 1's and this can be calculated in a nano-second.

My offered solution is this. Let's have three Crowns. The first Crown

goes to Michael for the under 1 second published Coverage Calculation
code. The second Crown goes to you for the best Windows Cover/Wheel


generator with repeat subsets allowed - you have no real opposition so
there should be no dissension. The third Crown goes to me for
producing sets with no repeat subsets and once again there is no
competition and I don't mind if it is made of aluminium foil as long
as the 1000 diamonds are genuine. (We need a sponsor for that.)
However, in all three categories new contenders cannot be ruled out.
(Pesky creatures.)

Michael

unread,
May 7, 2009, 4:41:45 AM5/7/09
to

"Michael" <mik...@bigpond.com> wrote in message
news:PpcMl.8996$y61....@news-server.bigpond.net.au...
Was easier to code than expected. This thread getting too
unwieldly so I have published new code in new thread
"100 random lines coverage" Michael


0 new messages