Message80501
I'm afraid I don't have any real-world use cases. Originally, I assumed
that dropping the length argument will make the function iterate over
*all* combinations, which would enable me to write somehow twisted, one-
liner for _inefficiently_ solving knapsack problem.
max((comb for comb in all_combinations(zip(weights, values))
if sum(map(itemgetter(0), comb)) < LIM),
key=lambda comb: sum(map(itemgetter(1), comb)))
But unfortunately, this is far from being 'compelling'.
Regarding other issues you raised: I think it would be pretty clear for
the user, that the length of every combination might vary - that's what
he asked for. And the length might be computed by summing the lengths
counted using given formula, which is (for me at last) still explicit
enough. |
|
Date |
User |
Action |
Args |
2009-01-25 10:57:40 | konryd | set | recipients:
+ konryd, rhettinger, mark.dickinson, ezio.melotti |
2009-01-25 10:57:40 | konryd | set | messageid: <1232881060.65.0.315176775336.issue5048@psf.upfronthosting.co.za> |
2009-01-25 10:57:39 | konryd | link | issue5048 messages |
2009-01-25 10:57:38 | konryd | create | |
|