I have list of tuples/lists (-1, 0, 1) (-1, 1, 0) (-1, 2, -1) (-1, -1, 2) (0, 1, -1)
I need them to be : (-1, 1, 0) (-1, 2, -1)
I want (-1, 0, 1) and (-1, 1, 0) map to the same thing. I thought of something like set but that would remove any duplicates I might have in the tuple.
While generating a new tuple say (-1,-1,2) I want to perform a check like
if (-1,-1,2) in seen:
pass
else:
insert(seen, (-1,-1,2))
for this I need the data structure to be hashable for O(1) lookup. Any ideas how I would implement this in Python?
See Question&Answers more detail:os