I was wondering if there is an algorithm that can return the intersection of all possible combinations of n different lists. My example is the following with n = 3 different lists:
list1 = [1,2,3,4,5]
list2 = [1,3,5]
list3 = [1,2,5]
the outcome should look like this:
list1_2_intersection = [1,3,5]
list1_3_intersection = [1,2,5]
list2_3_intersection = [1,5]
list1_2_3_intersection = [1,5]
I was thinking to first use combination
to get all possible combinations of n sets and use that to create intersections using intersection
manually. However, since I have 6 different sets this seems very time consuming, which is why I was wondering if there is a more efficient way to compute this. Thanks in advance! :)