recursive algorithm for balls in numbered boxes

Dr. Phillip M. Feldman Phillip.M.Feldman at
Sat Sep 10 20:43:39 EDT 2011

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.

Also, I'd like to get this functionality into the Python's `itertools`
module (the present set of combinatorics functions in `itertools` does not
include "balls in boxes").  Does anyone know whom I should contact about

View this message in context:
Sent from the Python - python-list mailing list archive at

More information about the Python-list mailing list