View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Paul Black Paul Black is offline
external usenet poster
 
Posts: 394
Default Calculate Last Digits

Hi Dana,

For interest.
To calculate them for the 6 numbers drawn in a Lotto draw I used ...
=SUMPRODUCT(--(RIGHT($O117:$T117,1)="0"))
=SUMPRODUCT(--(RIGHT($O117:$T117,1)="1"))
=SUMPRODUCT(--(RIGHT($O117:$T117,1)="2"))
=SUMPRODUCT(--(RIGHT($O117:$T117,1)="3"))
=SUMPRODUCT(--(RIGHT($O117:$T117,1)="4"))
=SUMPRODUCT(--(RIGHT($O117:$T117,1)="5"))
=SUMPRODUCT(--(RIGHT($O117:$T117,1)="6"))
=SUMPRODUCT(--(RIGHT($O117:$T117,1)="7"))
=SUMPRODUCT(--(RIGHT($O117:$T117,1)="8"))
=SUMPRODUCT(--(RIGHT($O117:$T117,1)="9"))
.... to calculate the last digit for the 6 numbers, I used ...
=SUM(DO117:DX117)
.... to check the total was 6 (for 6 numbers drawn), then ...
=--
CONCATENATE(DO117,DP117,DQ117,DR117,DS117,DT117,DU 117,DV117,DW117,DX117)
.... to string them together, and ...
=LARGE(DO117:DX117,1)*100000+LARGE(DO117:DX117,2)* 10000+LARGE(DO117:DX117,3)*1000+LARGE(DO117:DX117, 4)*100+LARGE(DO117:DX117,5)*10+LARGE(DO117:DX117,6 )
.... to transfer them into the category.

Hope this helps.
All the Best.
Paul

On Oct 10, 3:46 pm, Paul Black wrote:
Hi Dana,

Here are the formulas I used to calculate the last digits in a 649
Lotto. This is assuming that ALL numbers from 1 to 49 are 2 digits.
For example, 1 is 01 etc.

111111 = 2,887,500 combinations
=COMBIN(9,6)*COMBIN(5,1)*COMBIN(5,1)*COMBIN(5,1)*C OMBIN(5,1)*COMBIN(5,1)*CO*MBIN(5,1)+COMBIN(9,5)*CO MBIN(5,1)*COMBIN(5,1)*COMBIN(5,1)*COMBIN(5,1)*COMB I*N(5,1)*COMBIN(1,1)*COMBIN(4,1)

211110 = 6,930,000 combinations
=COMBIN(9,1)*COMBIN(5,2)*COMBIN(8,4)*COMBIN(5,1)*C OMBIN(5,1)*COMBIN(5,1)*CO*MBIN(5,1)+COMBIN(9,1)*CO MBIN(5,2)*COMBIN(8,3)*COMBIN(5,1)*COMBIN(5,1)*COMB I*N(5,1)*COMBIN(1,1)*COMBIN(4,1)+COMBIN(9,4)*COMBI N(5,1)*COMBIN(5,1)*COMBIN(5*,1)*COMBIN(5,1)*COMBIN (1,1)*COMBIN(4,2)

221100 = 2,772,000 combinations
=COMBIN(9,2)*COMBIN(5,2)*COMBIN(5,2)*COMBIN(7,2)*C OMBIN(5,1)*COMBIN(5,1)+CO*MBIN(9,2)*COMBIN(5,2)*CO MBIN(5,2)*COMBIN(7,1)*COMBIN(5,1)*COMBIN(1,1)*COMB I*N(4,1)+COMBIN(9,1)*COMBIN(5,2)*COMBIN(8,2)*COMBI N(5,1)*COMBIN(5,1)*COMBIN(1*,1)*COMBIN(4,2)

222000 = 105,600 combinations
=COMBIN(9,3)*COMBIN(5,2)*COMBIN(5,2)*COMBIN(5,2)+C OMBIN(9,2)*COMBIN(5,2)*CO*MBIN(5,2)*COMBIN(1,1)*CO MBIN(4,2)

311100 = 924,000 combinations
=COMBIN(9,1)*COMBIN(5,3)*COMBIN(8,3)*COMBIN(5,1)*C OMBIN(5,1)*COMBIN(5,1)+CO*MBIN(9,1)*COMBIN(5,3)*CO MBIN(8,2)*COMBIN(5,1)*COMBIN(5,1)*COMBIN(1,1)*COMB I*N(4,1)+COMBIN(9,3)*COMBIN(5,1)*COMBIN(5,1)*COMBI N(5,1)*COMBIN(1,1)*COMBIN(4*,3)

321000 = 316,800 combinations
=COMBIN(9,1)*COMBIN(5,3)*COMBIN(8,1)*COMBIN(5,2)*C OMBIN(7,1)*COMBIN(5,1)+CO*MBIN(9,1)*COMBIN(5,3)*CO MBIN(8,1)*COMBIN(5,2)*COMBIN(1,1)*COMBIN(4,1)+COMB I*N(9,1)*COMBIN(5,3)*COMBIN(8,1)*COMBIN(5,1)*COMBI N(1,1)*COMBIN(4,2)+COMBIN(9*,1)*COMBIN(5,2)*COMBIN (8,1)*COMBIN(5,1)*COMBIN(1,1)*COMBIN(4,3)

330000 = 3,960 combinations
=COMBIN(9,2)*COMBIN(5,3)*COMBIN(5,3)+COMBIN(9,1)*C OMBIN(5,3)*COMBIN(1,1)*CO*MBIN(4,3)

411000 = 39,600 combinations
=COMBIN(9,1)*COMBIN(5,4)*COMBIN(8,2)*COMBIN(5,1)*C OMBIN(5,1)+COMBIN(9,1)*CO*MBIN(5,4)*COMBIN(8,1)*CO MBIN(5,1)*COMBIN(1,1)*COMBIN(4,1)+COMBIN(9,2)*COMB I*N(5,1)*COMBIN(5,1)*COMBIN(1,1)*COMBIN(4,4)

420000 = 3,960 combinations
=COMBIN(9,1)*COMBIN(5,4)*COMBIN(8,1)*COMBIN(5,2)+C OMBIN(9,1)*COMBIN(5,4)*CO*MBIN(1,1)*COMBIN(4,2)+CO MBIN(9,1)*COMBIN(5,2)*COMBIN(1,1)*COMBIN(4,4)

510000 = 396 combinations
=COMBIN(9,1)*COMBIN(5,5)*COMBIN(8,1)*COMBIN(5,1)+C OMBIN(9,1)*COMBIN(5,5)*CO*MBIN(1,1)*COMBIN(4,1)

Making a grand total of 13,983,816 combinations.

All the Best.
Paul

On Oct 10, 2:47 pm, "Dana DeLouis" wrote:



Hi. No, I used another program. I'm not sure how I would do this using
Excel vba in a reasonable amount of time.
Actually, I'd be curious to learn how you did it using Combin. I'd be
interested to learn If you can do this via formulas. I sure don't see it.
:~


--
Thanks
Dana DeLouis


"Paul Black" wrote in message


roups.com...


Thanks for the reply Dana,


I worked out the results using the COMBIN formula in Excel for each
category.
I am reasonably new to VBA and thought it would be a good excercise to
create the same answers using VBA. I realise now that this is a much
bigger task than I can manage.
I don't need the 13,983,816 combinations themselves, I was just trying
to produce the total combinations for each last digit category. The
code I produced was what I thought was needed to achieve this.
When you say ...
However, I now get the same solution as you. I really don't see where
the error was in my previous code.
... does that mean you have the code to produce the results I am
looking for please?.


Thanks in Advance.
All the Best.
Paul


On Oct 10, 7:01 am, "Dana DeLouis" wrote:
Well, I apologize. I just attacked the problem from a different method
and
got the time down to about 2 minutes.
However, I now get the same solution as you. I really don't see where
the
error was in my previous code.
Are you trying to use Excel to verify the solution? I'm curious where
you
got the answers.
Anyway, I'm not sure how long Excel would take to arrive at a solution,
but
I'm guessing a very long time.


LastDigit = i - 10 * Int(i) / 10


I can't follow your code to well, but in the above, the variable 'I' is
already an integer, so you are not doing much to "I"
It "appears" you meant something like "Int(I/10)*10 to extract the last
digit.
Just to mention, the last digit is also = Mod(n,10)


Your initial set are the numbers 1-49. After generating all 13,983,816
subsets, you extract the last digit of each.
That's =6*COMBIN(49,6), or 83,902,896 different Mod () operations alone.
I suggest starting with a set with just the last digit. (ie apply the Mod
to
each of the 49 numbers.)
Then go into your Subset routine.


Anyway, I get the same solution as you, so please disregard my previous
attempt.
--
Dana DeLouis


<snip- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -