recursive algorithm for balls in numbered boxes

Chris Rebert clp2 at
Sun Sep 11 04:18:47 CEST 2011

On Sat, Sep 10, 2011 at 5:43 PM, Dr. Phillip M. Feldman
<Phillip.M.Feldman at> wrote:
> I've written a recursive class that creates an iterator to solve a general
> formulation of the combinatorics problem known as "balls in numbered boxes"
> (also known as "indistinguishable balls in distinguishable boxes").  The
> code has been extensively tested and appears to work, but isn't terribly
> elegant.  Any suggestions about how to improve it will be appreciated.

Significantly refactored (but untested) version:


More information about the Python-list mailing list