I have two lists of 12 items and I want to compute the following:
-12 sets of combinations of the items so each item have been combined with each other on the other list after the 12 times. Simplified example:
list_a = ['a','b','c','d']
list_b = ['blue','green','red','white']
The 4 sets of combinations would be:
[
[['a','blue'], ['b','green'], ['c','red'], ['d','white']],
[['a','white'], ['b','red'], ['c','green'], ['d','blue']],
[['a','green'], ['b','white'], ['c','blue'], ['d','red']],
[['a','red'], ['b','blue'], ['c','white'], ['d','green']]
]
I tried with itertools but I get out of memory errors
Edit: I need to get the set with unique combinations. Not ['a','blue'],['a','green']...
More like in the example that I posted earlier
itertoolscode? Since you need 144 combinations, it seems something wrong to have OOM errorimport itertools; list(itertools.product(list_a, list_b))will do what you want