fork download
  1. # your code goes here
  2. from itertools import product
  3.  
  4. tamax = 10
  5. tamin = tamax * 0.95
  6. tamanhos = [1, 3, 6, 3, 1]
  7. results = set()
  8. for size in range(1, len(tamanhos) + 1):
  9. for p in product(tamanhos, repeat=size):
  10. if tamin <= sum(p) <= tamax:
  11. results.add(tuple(sorted(p)))
  12.  
  13. print (list(map(list, results)))
Success #stdin #stdout 0.02s 9144KB
stdin
Standard input is empty
stdout
[[1, 3, 6], [1, 1, 1, 1, 6], [1, 3, 3, 3]]