class Ensemble: def __init__(self): self.taille = 0 self.paquets = [[] for _ in range(23)] def contient(self, x): return x in self.paquets[x % 23] def ajoute(self, x): if not self.contient(x): self.taille += 1 self.paquets[x % 23].append(x) def contient_doublon(t): s = Ensemble() for x in t: if s.contient(x): return True s.ajoute(x) return False