from itertools import* f=lambda d,t,l:set(tuple(sorted(i+d))for i in product(d,repeat=l-len(d))if sum(i+d)==t) print(f((1,2,3),36,15))
Standard input is empty
{(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)}