|
|
|
|
|
by hprotagonist
2070 days ago
|
|
sets are great. A slightly janky but very tidy way to know if a list of (hashable) things has any duplicates in python is to test len(set(mylist)) == len(mylist)
which probably loses on big O to some more clever approaches but is just fine for small n, and very readable.Other trivially answerable questions include “what’s in me but not in this other collection”, “what’s in both of us”, “what’s in exactly one of us”, ... etc. |
|