Skip to content

Instantly share code, notes, and snippets.

@larsga larsga/kata.py
Created Mar 28, 2012

Embed
What would you like to do?
Anagram code kata
def make_key(str):
key = list(str)
key.sort()
return "".join(key)
classes = {}
for line in open("wordlist.txt"):
word = line.strip().lower()
key = make_key(word)
words = classes.get(key, set())
if not words:
classes[key] = words
words.add(word)
for words in classes.values():
if len(words) > 1:
print words
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.