all combinations from two lists [message #75652] |
Mon, 14 March 2011 12:40 |
Jeremy Bailin
Messages: 618 Registered: April 2008
|
Senior Member |
|
|
I'm sure this is possible using some variant of JD's histogram-of-histogram approach, but I'm getting very bogged down in the details, so maybe someone can disentangle it.
I have two lists of IDs. I would like a list of every time an ID appears in both lists. But each ID can appear multiple times in each list, and I would like all combinations. For example:
list1 = [0,1,4,7,8,4,7,4,9]
list2 = [0,6,8,4,4,9,10]
I would like an output list that contains:
0 0 (indices of "0" in both)
2 3
2 4
5 3
5 4
7 3
7 4 (all permutations of where "4" appears in both)
4 2 (indices of "8" in both)
8 5 (indices of "9" in both)
Each list contains millions of elements, so it shouldn't loop through elements or IDs.
-Jeremy.
|
|
|