lotto number generator

Ian Kelly ian.g.kelly at gmail.com
Mon Jun 1 13:13:39 EDT 2015


On Mon, Jun 1, 2015 at 10:23 AM, gm <notMyMail at mail.not> wrote:
> Hi.
> I am new to python so am still in learning phase.
>
> I was thinking to make one program that will print out all possible
> combinations of 10 pairs. I think this is a good way for something "bigger"
> :-).
>
> This is how this looks like:
>
> 1.) 1 2
> 2.) 1 2
> 3.) 1 2
> 4.) 1 2
> 5.) 1 2
> 6.) 1 2
> 7.) 1 2
> 8.) 1 2
> 9.) 1 2
> 10.) 1 2
>
> So, i want to print out (in rows) each possible configuration but for all 10
> pairs.
>
> example:
> 1 1 1 2 2 2 2 1 1 1
> 2 2 2 1 1 1 1 2 2 2
> 1 1 2 2 1 1 2 2 1 1
> etc.
>
> What would be the best way to make something like this ?
> Maybe some tutorial ?

The Python tutorial is a good place to start:

    https://docs.python.org/3.4/tutorial/index.html

For your particular problem you'll probably want to use the
itertools.product function:

    https://docs.python.org/3.4/library/itertools.html#itertools.product

I wouldn't recommend printing out every possible combination to the
screen, though. That's over a million rows! Start with fewer pairs (4
is probably good), or write them to a file instead.



More information about the Python-list mailing list