On Wed, 14 Mar 2007 19:25:46 +1100, Steven D'Aprano wrote:

> Now that I've seen your _partition() function, I'm quite impressed. It is
> still brute-force, but it avoids generating all 50**5 non-unique lists. By
> my count, it only has to throw away 11,294 lists to generate the 2611
> unique lists it returns.

Ignore that count. I don't know where I got 11,294 from, the correct
figure is 10,358.

Oh, I seem to have found a bug in the _partitions() function. I believe it
is missing some of the partitions.

>>> list(_partitions(25, 24))
[(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2)]
>>> list(_partitions(25, 25))
[]


-- 
Steven D'Aprano 

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to