from itertools import combinations lis = [25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46] dic = {} for i in range(10, len(lis)): n = 0; for comb in combinations(lis, i): s = sum(comb); if 280 <= s <= 520: if s not in dic: dic[s] = [] dic[s].append(comb) print(dic[300])
Standard input is empty
[(25, 26, 27, 28, 29, 30, 31, 32, 33, 39), (25, 26, 27, 28, 29, 30, 31, 32, 34, 38), (25, 26, 27, 28, 29, 30, 31, 32, 35, 37), (25, 26, 27, 28, 29, 30, 31, 33, 34, 37), (25, 26, 27, 28, 29, 30, 31, 33, 35, 36), (25, 26, 27, 28, 29, 30, 32, 33, 34, 36), (25, 26, 27, 28, 29, 31, 32, 33, 34, 35)]