Вы можете сделать что-то вроде этого:
from itertools import permutations, product, chain
test = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
groups = [[1], [2, 3, 4], [5], [6, 7], [8, 9], [10], [11, 12, 13], [14], [15, 16]]
result = [list(chain.from_iterable(permutation)) for permutation in product(*map(permutations, groups))]
for e in result[:20]:
print(e)
выход
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 15]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 12, 14, 15, 16]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 12, 14, 16, 15]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 11, 13, 14, 15, 16]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 11, 13, 14, 16, 15]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 11, 14, 15, 16]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 11, 14, 16, 15]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 11, 12, 14, 15, 16]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 11, 12, 14, 16, 15]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 12, 11, 14, 15, 16]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 12, 11, 14, 16, 15]
[1, 2, 3, 4, 5, 6, 7, 9, 8, 10, 11, 12, 13, 14, 15, 16]
[1, 2, 3, 4, 5, 6, 7, 9, 8, 10, 11, 12, 13, 14, 16, 15]
[1, 2, 3, 4, 5, 6, 7, 9, 8, 10, 11, 13, 12, 14, 15, 16]
[1, 2, 3, 4, 5, 6, 7, 9, 8, 10, 11, 13, 12, 14, 16, 15]
[1, 2, 3, 4, 5, 6, 7, 9, 8, 10, 12, 11, 13, 14, 15, 16]
[1, 2, 3, 4, 5, 6, 7, 9, 8, 10, 12, 11, 13, 14, 16, 15]
[1, 2, 3, 4, 5, 6, 7, 9, 8, 10, 12, 13, 11, 14, 15, 16]
[1, 2, 3, 4, 5, 6, 7, 9, 8, 10, 12, 13, 11, 14, 16, 15]
UPDATE
Учитывая новые ограничения, вы можете сделать что-то вроде этого:
from functools import partial
from itertools import combinations, permutations, product, chain
choose_one = partial(lambda r, iterable: combinations(iterable, r), 1)
groups = [[[1]], combinations([6, 11], 1), permutations([2, 12]), [[5]], combinations([13, 14, 15], 1)]
for e in product(*groups, repeat=1):
print(list(chain.from_iterable(e)))
выход
[1, 6, 2, 12, 5, 13]
[1, 6, 2, 12, 5, 14]
[1, 6, 2, 12, 5, 15]
[1, 6, 12, 2, 5, 13]
[1, 6, 12, 2, 5, 14]
[1, 6, 12, 2, 5, 15]
[1, 11, 2, 12, 5, 13]
[1, 11, 2, 12, 5, 14]
[1, 11, 2, 12, 5, 15]
[1, 11, 12, 2, 5, 13]
[1, 11, 12, 2, 5, 14]
[1, 11, 12, 2, 5, 15]