Find combinations of size r from a set with decreasing sum value
问题 I have a set of numbers eg. [100,90,80,70,60,50] and want to find all combinations of size r=3 but in order of decreasing sum. Arranging the numbers in decreasing order does not work eg. (100, 90, 80) 270 (100, 90, 70) 260 (100, 90, 60) 250 (100, 90, 50) **240** (100, 80, 70) **250** (100, 80, 60) 240 How can i go about finding such a combination set with decreasing sum value. 回答1: Here' the Code import itertools array = [100,90,80,70,60,50] size = 3 answer = [] # to store all combination