lotto number generator

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


On Mon, Jun 1, 2015 at 11:13 AM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> 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.

Er, actually it's just 1024, so that isn't so bad. You probably still
don't want all that in your terminal, though.



More information about the Python-list mailing list