[issue12961] itertools: unlabelled balls in boxes

2011-09-24 Thread Phillip Feldman
Phillip Feldman phillip.m.feld...@gmail.com added the comment: Raymond- I think that you may have overestimated the complexity of the problem. In about 5 hours, I coded, debugged, and documented a set of generator functions to solve the general formulation (including box limits) for three

[issue12961] itertools: unlabelled balls in boxes

2011-09-21 Thread Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com added the comment: Sorry Phillip, I'm closing this feature request because the benefits would likely be outweighed by the costs (maintenance, learning curve, module complexity, etc). It was not the goal of the module to become a complete

[issue12961] itertools: unlabelled balls in boxes

2011-09-20 Thread Phillip Feldman
Phillip Feldman phillip.m.feld...@gmail.com added the comment: Mark: I disagree with your claim that in its basic form, this is covered by itertools.combinations. If you open the attached text on elementary combinatorics and go to page 11, you will see a table that lays out six of the eight

[issue12961] itertools: unlabelled balls in boxes

2011-09-20 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Mark: I disagree ... Okay, I misunderstood. I thought you were still talking about the unlabelled balls in labelled boxes problem, which is an isomorphic problem to that solved by combinations_with_replacement. It looks as though you're

[issue12961] itertools: unlabelled balls in boxes

2011-09-20 Thread Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com added the comment: Any additions would need to be motivated by real world problems. The issue is that adding more generators makes the module harder to learn and remember, so tools are not usually added for the sake of completeness. --

[issue12961] itertools: unlabelled balls in boxes

2011-09-20 Thread Phillip Feldman
Phillip Feldman phillip.m.feld...@gmail.com added the comment: Ideally, I'd like to see support for all combinations of the following occupancy problem features: - Labeled and unlabeled boxes - Labeled and unlabeled balls - Empty boxes allowed and empty boxes forbidden - Boxes with no capacity

[issue12961] itertools: unlabelled balls in boxes

2011-09-20 Thread Phillip Feldman
Phillip Feldman phillip.m.feld...@gmail.com added the comment: With the exception of the empty boxes forbidden category, I've come across all of these at one time or another, many in the context of error control coding (data communications). Much of the early work on occupancy problems was

[issue12961] itertools: unlabelled balls in boxes

2011-09-19 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: Balls-in-boxes _is_ one of the most basic of the canonical combinatorial problems. Agreed. But in its basic form, this is covered by itertools.combinations, isn't it? It may be worth a doc recipe showing how to use

[issue12961] itertools: unlabelled balls in boxes

2011-09-19 Thread Mark Dickinson
Mark Dickinson dicki...@gmail.com added the comment: And using combinations_with_replacement, it's even a one-liner: balls_in_boxes = lambda n, k: (tuple(map(c.count, range(k))) for c in combinations_with_replacement(range(k), n)) for item in balls_in_boxes(5,3): print(item) ... (5, 0, 0)

[issue12961] itertools: unlabelled balls in boxes

2011-09-17 Thread Georg Brandl
Changes by Georg Brandl ge...@python.org: -- title: unlabelled balls in boxes - itertools: unlabelled balls in boxes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12961 ___

[issue12961] itertools: unlabelled balls in boxes

2011-09-17 Thread Raymond Hettinger
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- priority: normal - low ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12961 ___ ___

[issue12961] itertools: unlabelled balls in boxes

2011-09-17 Thread Phillip Feldman
Phillip Feldman phillip.m.feld...@gmail.com added the comment: The itertools module should only have a few of the most generally useful, especially in combination with other tools. Balls-in-boxes _is_ one of the most basic of the canonical combinatorial problems. You can verify this by