number generator

Paul Rubin http
Wed Mar 14 03:08:38 EDT 2007


Steven D'Aprano <steve at REMOVEME.cybersource.com.au> writes:
> > It should be possible to enumerate all sets of five numbers which sum
> > to 50 and randomly select one of them.
> 
> Of course it's possible. It's also a very inefficient way of doing so. For
> five numbers between 1 and 50, there are 50**5 = 312,500,000 possible sets
> to enumerate. 

No there are only 2611 such sets and generating them takes about 0.5
seconds on my laptop.  I posted the code for this elsewhere in the thread.



More information about the Python-list mailing list