Raymond Hettinger wrote:

> To make the solutions equi-probable, a simple approach is to
> recursively enumerate all possibilities and then choose one of them
> with random.choice().

Maybe it is possible to generate the possibilities by an indexing 
function and then use randint to pick one of them. I suppose this is 
like the bricks and bins problem this thread was about:

http://groups.google.nl/group/comp.lang.python/browse_thread/thread/4782b54fa39b3bad

Except that the bins now have at least 1 brick in them (if we have 
positive numbers).

I posted a rather simplistic solution (but working I think) after Steven 
Taschuk made some insightful remarks. I believe it is possible to 
generate the list of numbers directly instead of permuting a list of '0' 
and '1' characters and then finding the positions of the '1' elements.

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

Reply via email to