Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91692 > unrolled thread

lotto number generator

Started bygm <notMyMail@mail.not>
First post2015-06-01 18:23 +0200
Last post2015-06-01 11:16 -0600
Articles 4 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  lotto number generator gm <notMyMail@mail.not> - 2015-06-01 18:23 +0200
    Re: lotto number generator Grant Edwards <invalid@invalid.invalid> - 2015-06-01 17:07 +0000
    Re: lotto number generator Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-01 11:13 -0600
    Re: lotto number generator Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-01 11:16 -0600

#91692 — lotto number generator

Fromgm <notMyMail@mail.not>
Date2015-06-01 18:23 +0200
Subjectlotto number generator
Message-ID<mki0um$q97$1@l01news1.ot.hr>
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

[toc] | [next] | [standalone]


#91695

FromGrant Edwards <invalid@invalid.invalid>
Date2015-06-01 17:07 +0000
Message-ID<mki3gi$bv3$2@reader1.panix.com>
In reply to#91692
On 2015-06-01, gm <notMyMail@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            

[toc] | [prev] | [next] | [standalone]


#91698

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-06-01 11:13 -0600
Message-ID<mailman.6.1433178862.13271.python-list@python.org>
In reply to#91692
On Mon, Jun 1, 2015 at 10:23 AM, gm <notMyMail@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.

[toc] | [prev] | [next] | [standalone]


#91699

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-06-01 11:16 -0600
Message-ID<mailman.7.1433179038.13271.python-list@python.org>
In reply to#91692
On Mon, Jun 1, 2015 at 11:13 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Mon, Jun 1, 2015 at 10:23 AM, gm <notMyMail@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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web