ยง Words that can be distinguished from letters if we know the sign of the permutation
with open("google-10000-english.txt", "r") as f:
words = [w.strip() for w in f.readlines()]
sorted = {}
for w in words:
wsort = list(w)
wsort.sort()
wsort = "".join(wsort)
if wsort in sorted:
sorted[wsort].append(w)
else:
sorted[wsort] = [w]
collisions = 0
for wk in sorted:
if len(sorted[wk]) == 1: continue
collisions += 1
print(sorted[wk])
print("---")
print(collisions, len(words), 100.0 * float(collisions) / len(words))
collisions = 0
for wk in sorted:
collidews = sorted[wk]
for i in range(len(collidews):
for j in range(i+1, len(collidews))
collisions += 1
print(sorted[wk])
print("---")