-1

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]]
Toadman30
  • 31
  • 3

1 Answers1

0

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)
Julien
  • 13,986
  • 5
  • 29
  • 53