View Single Post
  #4   Report Post  
Martin-888 Martin-888 is offline
Junior Member
 
Posts: 4
Default

Quote:
Originally Posted by joeu2004[_2_] View Post

I would like to help.

But first, let's agree to ignore those whose only comment is to pontificate
about how foolish playing the lottery is. Yes, yes, yes; just like all
gambling. But it presents some very interesting, if not fun, mathematical
problems. After all, it was the analysis of games of chance that gave rise
to probability theory in the first place.

So I am not judging your motivations. "Frankly, my dear, I don't give a
damn!" :-)

But I am curious, because this question has come up before.

So please explain the context of this question.

For example, is it a class assignment?

Or is it part of a lottery strategy? If so, can you explain the strategy,
or can you point to a (free) website that does?
First of all, thank you for being interested in my question :)

It is part of a lottery strategy, but it does imply buying all the 320 combinations (which I'll explain why I think there is only 320 combinations later), therefore guaranteeing at least one win of the 4 out of 6 prize. Also I just want to point out that English isn't my native language, sometimes I run out of word to properly explain my thought :)

Quote:
Originally Posted by joeu2004[_2_] View Post
Based on this example, I think a better description of your objective is:
all combinations of 6 out of 36 numbers with a unique set of 4 numbers.

It has nothing to do with "winning" 4 out of 6. To me, that means:
matching 4 out of 6 compared to some drawing of 6 numbers. That's a very
different problem; an easier problem to solve, IMHO.

Anyway, what makes you think there are only "around 320" such combinations?

I believe the correct count is 2240.
I'm not very good in math, but since there is 1 chance out of 320, it made me believe that there was many groups of 320 combinations. Having Excel taking out all of the matching combinations would answer that question.

Just to make sure that I'm properly understood, I want to clarify a point.

In my 4 out of 6 unique combinations, the 4 out of 6 has to be completely unique:

If you take 1,2,3,4,5,6 as my starting combination, the other combinations will not be able to have the following inside of them:

1,2,3,4
2,3,4,5
3,4,5,6
1,3,4,5
1,4,5,6
2,4,5,6
1,2,4,5
1,2,5,6
1,3,4,6
1,3,5,6
1,4,5,6

So for the script to work properly, the next logical combination would be 1,2,3,7,8,9 since 1,2,3,4,5,7 wouldn't be an acceptable one. Also, starting with the first combination being 2,3,4,5,6,7 then this creates a different list of combinations, with different exclusions. I hope this makes more sense?

Quote:
Originally Posted by joeu2004[_2_] View Post
At the risk of reinventing the wheel (I cannot find my comments in the
previous discussion), I implemented an algorithm that counts and generates
all of the qualified combinations by exhaustively generating all
COMBIN(36,6) combinations (1,947,792) and keeping track of the ones with
unique sets of 4 numbers. It only takes about 1 second on my computer.
(YMMV.)

I will share that implementation with you after you answer my questions
above.

In the meantime, I am still improving the implmentation so it is easier for
public consumption. I would also like to see if there is a better
algorithm. And I am still strugging to derive a computational method for
counting the number of combinations.

In any case, be advised that this cannot be done with Excel alone. Instead,
it requires a VBA subroutine (macro). Is that acceptable?
VBA script is perfect, I didn't think that Excel alone would be able to create this either. Is this how you first understood my question or my clarification changes it? Also, your algorithm that creates all the combinations within 1 second is impressive, all the ones I found online takes nearly 1 hour to complete and I have a Core i7.

Please let me know if you need more info :)

Thanks!