Steven D'Aprano <[EMAIL PROTECTED]> writes: > If you generate all the possible sets of five numbers between 1 and 50, > there are 50**5 of them, not 2611.
Yes, the idea is generate only the sets that add up to 50. > unique_partitions(60, 6) takes 0.8 seconds; unique_partitions(80, 8) > takes about 25 seconds; unique_partitions(80, 10) takes about 80 seconds, > and unique_partitions(81, 10) takes over 90 seconds. Hmm, interesting. Maybe some more optimization is possible. > (E.g. unique_partitions(80, 10) returns 533,975 unique lists. > _partitions(80, 10) gives 3,233,568 non-unique lists.) Well that's just 6x "inflation" due to duplicates, so I dunno what else can be done for exhaustive enumeration. Maybe another approach to generating the k'th partition is possible. I'll try to think about this. -- http://mail.python.org/mailman/listinfo/python-list