fork download
  1. from itertools import*
  2. f=lambda d,t,l:[i+d for i in combinations_with_replacement(d,l-len(d))if sum(i+d)==t]
  3.  
  4. print(f((1,2,3),36,15))
Success #stdin #stdout 0.02s 9984KB
stdin
Standard input is empty
stdout
[(1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 2, 3), (1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 1, 2, 3), (1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 1, 2, 3), (2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 1, 2, 3)]