fork(1) download
  1. from itertools import*
  2. f=lambda d,t,l:set(tuple(sorted(i+d))for i in product(d,repeat=l-len(d))if sum(i+d)==t)
  3.  
  4. print(f((1,2,3),36,15))
Success #stdin #stdout 0.48s 9936KB
stdin
Standard input is empty
stdout
{(1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3), (1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3), (1, 1, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), (1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3)}