Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91699
| References | <mki0um$q97$1@l01news1.ot.hr> <CALwzidk1Rg7oODLYvKC9JgLbbB8Kd3y-XWsUBv5s3qRvORV9Nw@mail.gmail.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2015-06-01 11:16 -0600 |
| Subject | Re: lotto number generator |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7.1433179038.13271.python-list@python.org> (permalink) |
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.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
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
csiph-web