Today at school the teacher asked us to implement a duplicate-deletion algorithm. It\'s not that difficult, and everyone came up with the following solution (pseudocode):
def dedup(l):
ht, et = [(None, None) for _ in range(len(l))], []
for e in l:
h, n = hash(e), h % len(ht)
while True:
if ht[n][0] is None:
et.append(e)
ht[n] = h, len(et) - 1
if ht[n][0] == h and et[ht[n][1]] == e:
break
if (n := n + 1) == len(ht):
n = 0
return et