fork download
  1. from itertools import combinations
  2.  
  3. lis = [25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46]
  4.  
  5. dic = {}
  6.  
  7. for i in range(10, len(lis)):
  8. n = 0;
  9. for comb in combinations(lis, i):
  10. s = sum(comb);
  11. if 280 <= s <= 520:
  12. if s not in dic:
  13. dic[s] = []
  14. dic[s].append(comb)
  15.  
  16. print(dic[300])
  17.  
  18.  
Success #stdin #stdout 2.5s 436724KB
stdin
Standard input is empty
stdout
[(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)]