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


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

Re: recursive algorithm for balls in numbered boxes

Started byPeter Otten <__peter__@web.de>
First post2011-09-11 22:13 +0200
Last post2011-09-11 22:13 +0200
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: recursive algorithm for balls in numbered boxes Peter Otten <__peter__@web.de> - 2011-09-11 22:13 +0200

#13149 — Re: recursive algorithm for balls in numbered boxes

FromPeter Otten <__peter__@web.de>
Date2011-09-11 22:13 +0200
SubjectRe: recursive algorithm for balls in numbered boxes
Message-ID<mailman.1007.1315771976.27778.python-list@python.org>
Dr. Phillip M. Feldman wrote:

> When I run my code, I get the same 14 configurations that your code
> produces; 

I'm sorry, I ran the buggy code from

http://old.nabble.com/file/p32439307/balls_in_numbered_boxes.py

without realizing it was not 

http://old.nabble.com/file/p32440187/balls_in_numbered_boxes.py

> 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.  

The outer loop is in a generator expression and thus evaluates lazily.

> 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.

Indeed; I should have added a disclaimer to make that clear.

[toc] | [standalone]


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


csiph-web