from collections import defaultdict
def canonical_form(word):
return tuple(sorted(word))
anagrams = defaultdict(list)
for word in open("/usr/share/dict/words"):
word = word.lower().strip()
anagrams[canonical_form(word)].append(word)
while True:
print anagrams[canonical_form(raw_input())]
听起来你在找一个能找到字谜的程序。这是一个非django解决方案。它使用Joel建议的/usr/share/dict/words。你知道吗
相关问题 更多 >
编程相关推荐