There are many questions that are related but none that I could find to do exactly what I am looking for. Essentially, I want to get all permutations of each sub-list put together for all possible combinations but keeping them separate. As such:
input=[[1,2,3],[4],[5,6]]
desired output:
[[1,2,3],[4],[6,5]]
[[2,1,3],[4],[5,6]]
[[2,1,3],[4],[5,6]]
[[3,1,2],[4],[5,6]]
etc...
I believe the following code will work, but I was wondering if there were any more efficient or succinct strategies. Thank you very much.
input=[[1,2,3],[4],[5,6]]
all_lists=[]
for i in xrange(len(input)):
all_lists.append(list(itertools.permutations(input[i])))
all_combinations = list(itertools.product(*all_lists))
## concat them together
combinations_combined = [list(itertools.chain(*a)) for a in all_combinations]
input, you override the reference to theinputbuiltin.