How can I get one combination for two sets of numbers?
alist =[[0, 1], [0, 2], [0, 3], [1, 0], [1, 2], [1, 3], [2, 0], [2, 1], [2, 3], [3, 0], [3, 1], [3, 2]]
I would like to return:
alist = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]]
Your question is not very clear. If I understood what you want to do: sort your pairs first then use set
to remove duplicates. Since lists are not hashable, convert your pairs to tuples before using set
:
set(tuple(sorted(x)) for x in alist)