from functools import reduce
def _enum_cands(total, length):
    for t in combinations_with_replacement(list(range(length)), 10):
        cand = [0] * length
for i in t:
    cand[i] += 1
yield tuple(cand)

def int_vec_with_sum(total, length):
    num_outcomes = reduce(mul, list(range(total + 1, total + length))) // factorial(
        length - 1)
idx = random.choice(list(range(num_outcomes)))
return next(islice(_enum_cands(total, length), idx, None))
Как создать список случайных целочисленных векторов, сумма которых равна x