lotto number generator

classic Classic list List threaded Threaded
4 messages Options
gm
Reply | Threaded
Open this post in threaded view
|

lotto number generator

gm
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 ?

GM

Reply | Threaded
Open this post in threaded view
|

lotto number generator

Grant Edwards-7
On 2015-06-01, gm <notMyMail at mail.not> wrote:

> I was thinking to make one program that will print out all possible
> combinations of 10 pairs.
[...]
> What would be the best way to make something like this?
> Maybe some tutorial ?

https://www.google.com/search?q=python+combinations

--
Grant Edwards               grant.b.edwards        Yow! A dwarf is passing out
                                  at               somewhere in Detroit!
                              gmail.com            

Reply | Threaded
Open this post in threaded view
|

lotto number generator

Ian Kelly-2
In reply to this post by gm
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.

Reply | Threaded
Open this post in threaded view
|

lotto number generator

Ian Kelly-2
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.