Lottery combinations

keith1

New Member
Joined
Nov 30, 2010
Messages
16
Hi
I am after the code to generate all the combinations of the UK lottery 6/49. Will excel hold this much data as it is nearly 14 mil combos.
Thanks
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Depending on if you want to actually use the data after you have generated it, you might want to store it in Access rather than Excel.
 
Upvote 0
I am after the code to generate all the combinations of the UK lottery 6/49. Will excel hold this much data as it is nearly 14 mil combos.

Excel will hold this much data but not in 14m rows of a single worksheet - you would have to use multiple columns or multiple worksheets. Either way, it will get messy.

Part of a project of probability on a stats course currently doing

The coding is trivial - off the top of my head it would be along the lines of:-
Code:
for p1=1 to 44
  for p2=p1+1 to 45
    for p3=p2+1 to 46
      for p4=p3+1 to 47
        for p5=p4+1 to 48
          for p6=p5+1 to 49
            debug.print p1; ;p2; ;p3; ;p4; ;p5; ;p6
          next p6
        next p5
      next p4
    next p3
  next p2
next p1

However having stored the combinations (somewhere/somehow), there's the problem of how you're going to access them - I mean, when you need to access the entry for 12/19/24/33/41/48 for example, how are you going to calculate where in the worksheet(s) it's stored?

MS Access will do this for you, in fact, but I would be looking for a solution which didn't involve storing all the combinations if possible.
 
Upvote 0
Just for interest and maybe to save you the trouble of trying this for yourself, I've just checked the time Access takes on my moderately-spec'd machine to:-
  • create a table of all 13.98m combinations: 14m37s
  • locate and update a single record: 0m28s
So if you're thinking about generating lots of random numbers and counting each combination via an Access table, the time taken to update the record for each combination will be 28 seconds. Multiply that by a meaningful number of samples and you're into run times of several hours if not days.

You might be better off using a 'smaller scale' lottery, perhaps something like five numbers out of twenty (15,504 possible combinations which will fit very easily on a worksheet and will be very easy to handle vis-a-vis graphs and charts), and deriving your statistics out of that.

Just my musings on the matter...
 
Upvote 0
I'm not sure you've said what "this" actually is. If you mean generating and storing the 13.98m combinations, I can post the VBA code to produce the table, but that's only the first step - even assuming it's a step in the right direction!

The real question is: what are you going to do with the table once you've got it?

Have you considered using a '5 from 20' model (for example) rather than a '6 from 49' one?
 
Upvote 0
I would like to generate all combinations and store them. Then I want to run a few tests to eliminate unlikely combinations based on previous draw history, such as all odds, or 6 numbers in a group of ten amongst others. If you could post the code for this, that would really help. I am a novice with access and vba, so any help is greatly appreciated. Thanks
 
Upvote 0

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top