Loop through Combinations and Keep a Count

P

Paul Black

Hi Everyone,

I will Try and Explain this as Clear as I can.
I have a 24 Number Abbreviated Wheel ( in Cells "G13:L27" ) of 15
Combinations with 6 Numbers in EACH Combination ( Other Wheels to Check
could have Less Or More Combinations than Currently so the Code will
Need to Recognise when it is the Last Combination to Check ).
Therefore, for this Example, there are 134,596 Combinations [ Excel
Formula COMBIN(24,6) ] in Total.
The Basis of what I am Trying to Achieve is to take the Wheel, Generate
ALL 134,596 Combinations for the Total Selected Numbers in the Wheel (
24 in this Example ) and Compare EACH Combination with the Lines in the
Wheel. Then Collate ALL the Results as Per the Categories Below.
So the Total Combinations "Covered" for the Matched Category 2 if 3 for
Example, Means the Total Combinations "Covered" in the Abbreviated
Wheel ( if it Matches then it is "Covered" and then go onto the Next
Combination to see if that Matches ) that have 2 Matched Numbers if I
have 3 Matched Numbers of the 6 Numbers Drawn Within my Selection.
So the Results ( I Don't Know if the "Covered" Results Below are
Accurate ) for EACH Category would Look something like this :-

Matched Tested Covered
2 if 2 276 209
2 if 3 2,024 2,008
2 if 4 10,626 10,626
2 if 5 42,504 42,504
2 if 6 134,596 134,596
3 if 3 2,024 300
3 if 4 10,626 5,289
3 if 5 42,504 35,720
3 if 6 134,596 131,922
4 if 4 10,626 225
4 if 5 42,504 4,140
4 if 6 134,596 35,304
5 if 5 42,504 90
5 if 6 134,596 1,635

I can see the Logic of what Needs to be Done, But Unfortunately I have
NO Idea how to Continue and Achieve the Required Results.

The Two Posts Below are what a Friend of mine says is the Bones of what
Needs to be Done.

-------------------------------------------------------
POST NUMBER 1
-------------------------------------------------------
the maths are straightforward to this. We have a wheel C(n,k,t,m)=b
where

*n=the total balls we want to wheel
*k=the ticket size (e.g. a 6 ball game has k=6)
*t=the prize division we want to guarantee a win
*m=the condition that has to be met, in order to guarantee the t prize
division win; m defines the least number of balls from our n set that
must be correct.
*b=the total tickets required to play.

Now, if you are interested to find the coverage achieved in a certain
category e.g. x if y, then the total combinations that need to be
covered are nCk(n,y)=A. Thus, you have to test A combinations, each one
containing y numbers against the tickets of your wheel (each ticket
contains k numbers).

A combination of those A is covered if there is at least one ticket in
your wheel, that contains at least x numbers in common. All you have to
do is to go through all A combinations and test each of them if it
contains at least x numbers in common with at least one ticket of your
wheel. If it does, then it is covered. Now, you have to convert this in
code.

-------------------------------------------------------
POST NUMBER 2
-------------------------------------------------------

You produce all combinations (not numbers) for the x if y category and
test each such combination (contains y numbers) if it is covered by at
least one combination in your wheel (k numbers). You don't test against
all numbers in the wheel. A combination of "x if y" is covered if there
is at least one ticket in your wheel that has in common t numbers.

e.g. for a simple wheel C(5,4,3,3)=4
1) 1 2 3 4
2) 1 2 3 5
3) 1 2 4 5
4) 1 3 4 5

we want to test the 2 if 3 (to be covered), nCk(5,3)=10 combinations
1 2 3
1 2 4
1 2 5
1 3 4
1 3 5
1 4 5
2 3 4
2 3 5
2 4 5
3 4 5

We go through all 10 combinations to find the coverage. E.g. we test 1
2 3 with our wheel. We can see that 1) & 2) & 3) & 4) tickets cover
this combination as they contain at least t=2 numbers in common, thus 1
2 3 is covered. We need only one ticket in the wheel to cover our
combination. If you test the above 10 combinations, all of them are
covered, thus the C(5,4,3,3)=4 has 2if3=100% coverage.

-------------------------------------------------------

So the End Result will give me the "Covered" Combinations for EACH of
the Categories ...

Match
2 if 2
2 if 3
2 if 4
2 if 5
2 if 6
3 if 3
3 if 4
3 if 5
3 if 6
4 if 4
4 if 5
4 if 6
5 if 5
5 if 6
6 if 6

ANY Help will be Greatly Appreciated.
All the Best.
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top