wingor2015
2020-05-20 10:57:43 +08:00
import itertools
def get_slice_unequal(nums, groups):
datas = itertools.combinations(nums, groups[0])
if len(groups) == 1:
return [[list(item)] for item in datas]
res = list()
for item in datas:
for sub_item in get_slice_unequal(list(set(nums) - set(item)), groups[1:]):
new_item = [list(item)]
res.append(new_item + sub_item)
return res
nums = [1, 2, 3, 4, 5, 6]
numsb = [2, 2, 1, 1]
res = get_slice_unequal(nums, numsb)
for item in res:
print(item)
print(len(res))