Let say that I have n lists and they are not disjoint. I want to make every combination of n elements which I get one from every lists I have but in that combination there are different elements and there are no double combination. So, [1,1,2]
isn't allowed and [1,2,3]
is same as [2,1,3]
.
For example, I have A=[1,2,3]
, B=[2,4,1]
, and C=[1,5,3]
. So, the output that I want is [[1,2,5],[1,2,3],[1,4,5],[1,4,3],[2,4,1],[2,4,5],[2,4,3],[3,2,5],[3,4,5],[3,1,5]]
.
I have search google and I think function product
in module itertools
can do it. But, I have no idea how to make no same elements in every combinations and no double combinations.
Maybe something like:
Of course you would have to change
3
ot the relevant value if you work with more than 3 lists.