Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91698
| Path | csiph.com!usenet.pasdenom.info!bete-des-vosges.org!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.022 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'subject:number': 0.07; '1.)': 0.09; 'python': 0.11; 'example:': 0.11; 'instead.': 0.15; '2.)': 0.16; ':-).': 0.16; 'combinations': 0.16; 'pairs': 0.16; 'screen,': 0.16; 'subject:generator': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; '(in': 0.18; 'am,': 0.23; '2015': 0.23; 'header :In-Reply-To:1': 0.24; 'mon,': 0.24; 'message-id:@mail.gmail.com': 0.28; 'looks': 0.29; 'function:': 0.29; 'tutorial': 0.29; 'maybe': 0.31; 'print': 0.31; 'probably': 0.32; 'url:python': 0.33; 'problem': 0.33; 'combination': 0.33; 'though.': 0.33; 'file': 0.34; 'received:google.com': 0.34; 'to:addr:python-list': 0.35; 'something': 0.35; 'but': 0.36; 'url:org': 0.36; 'possible': 0.36; 'url:library': 0.36; 'so,': 0.37; 'subject:: ': 0.37; 'url:docs': 0.39; 'to:addr:python.org': 0.39; 'some': 0.40; 'url:3': 0.60; 'your': 0.60; "you'll": 0.61; 'url:index': 0.64; 'url:4': 0.70; 'million': 0.73; 'to:name:python': 0.84; 'url:tutorial': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=9E+XZwfANcX81Xdl+nF7EfCrRTvVyV8oprrvuUbH0aY=; b=krgRcHCwW47iTiJqlosW9ZcL8bpBhgyjl0Yt7/qrd/EIh9AflnDaCmPqvP6VWW1kFw Zg2qI2ILJMx/tH4HNZ4Pz66GX2irjhRz0gthdTtSZ+MMygMg66wdVM10IygX6t00NVxx YCZiWwjVso/utMnejspf/ST3EORYutQQqDaenAq1+BBcIYEfiDt7u9lo5MtAX0hvO5XS Z7vCy/E7iVlOmlnhbKphA4hlwWyf6y5n0JfoPWYsRGtMALyUUQNvdRz3V8wAeGEp6DzO eS5Pjz9GwlCVGTAsn7LQDvSkS2vxl4a3Oi3oQKA1pELb36fneBKB84m+mIRm3Sa0D/nl uNXw== |
| X-Received | by 10.50.30.105 with SMTP id r9mr15017094igh.11.1433178859888; Mon, 01 Jun 2015 10:14:19 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <mki0um$q97$1@l01news1.ot.hr> |
| References | <mki0um$q97$1@l01news1.ot.hr> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Mon, 1 Jun 2015 11:13:39 -0600 |
| Subject | Re: lotto number generator |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6.1433178862.13271.python-list@python.org> (permalink) |
| Lines | 45 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1433178862 news.xs4all.nl 2936 [2001:888:2000:d::a6]:52394 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:91698 |
Show key headers only | View raw
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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next 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