Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #13146
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <bounces@nabble.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'rejected': 0.04; 'python': 0.08; '0),': 0.09; '[2]:': 0.09; 'context:': 0.09; 'output': 0.10; '(2,': 0.16; '1),': 0.16; 'iterator,': 0.16; 'message- id:@talk.nabble.com': 0.16; 'nabble.com.': 0.16; 'received:192.168.236': 0.16; 'received:192.168.236.156': 0.16; 'received:216.139': 0.16; 'received:216.139.236': 0.16; 'received:isper.nabble.com': 0.16; 'received:nabble.com': 0.16; 'url:nabble': 0.16; 'url:old': 0.16; "doesn't": 0.22; 'header:In- Reply-To:1': 0.22; 'archive': 0.23; 'thus': 0.23; 'testing': 0.24; 'code': 0.25; 'creating': 0.25; 'code,': 0.28; 'correct': 0.28; 'order.': 0.29; 'produced': 0.31; 'list': 0.32; 'cases': 0.32; 'too': 0.33; 'to:addr:python-list': 0.33; 'charset:us-ascii': 0.36; 'run': 0.37; 'subject:: ': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.39; 'mailing': 0.39; 'huge': 0.61; 'your': 0.61; 'total': 0.61; 'view': 0.67; 'subject:balls': 0.84; 'sum': 0.89 |
| Date | Sun, 11 Sep 2011 12:41:33 -0700 (PDT) |
| From | "Dr. Phillip M. Feldman" <Phillip.M.Feldman@gmail.com> |
| To | python-list@python.org |
| Subject | Re: recursive algorithm for balls in numbered boxes |
| In-Reply-To | <j4iamn$ave$1@dough.gmane.org> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Nabble-From | Phillip.M.Feldman@gmail.com |
| References | <32440187.post@talk.nabble.com> <j4iamn$ave$1@dough.gmane.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1004.1315770096.27778.python-list@python.org> (permalink) |
| Lines | 33 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1315770096 news.xs4all.nl 2413 [2001:888:2000:d::a6]:49057 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:13146 |
Show key headers only | View raw
Hello Peter, When I run my code, I get the same 14 configurations that your code produces; the only different that I can see in the output is that the configurations are produced in a different order. Note that your code is not creating an iterator, so thus doesn't do what I want. Also, generating the product set and then testing whether the total number of balls is correct will potentially consider a huge number of cases that must be rejected because the sum is wrong; this is too inefficient. Phillip In [2]: list(balls_in_numbered_boxes(10,[4,3,2,1,2])) Out[2]: [(4, 3, 2, 1, 0), (4, 3, 2, 0, 1), (4, 3, 1, 1, 1), (4, 3, 1, 0, 2), (4, 3, 0, 1, 2), (4, 2, 2, 1, 1), (4, 2, 2, 0, 2), (4, 2, 1, 1, 2), (4, 1, 2, 1, 2), (3, 3, 2, 1, 1), (3, 3, 2, 0, 2), (3, 3, 1, 1, 2), (3, 2, 2, 1, 2), (2, 3, 2, 1, 2)] -- View this message in context: http://old.nabble.com/recursive-algorithm-for-balls-in-numbered-boxes-tp32440187p32443548.html Sent from the Python - python-list mailing list archive at Nabble.com.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: recursive algorithm for balls in numbered boxes "Dr. Phillip M. Feldman" <Phillip.M.Feldman@gmail.com> - 2011-09-11 12:41 -0700
csiph-web