Skip to content

Instantly share code, notes, and snippets.

@mlbright
Created September 2, 2010 18:38
Show Gist options
  • Save mlbright/562704 to your computer and use it in GitHub Desktop.
Save mlbright/562704 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# anagram checker
from collections import defaultdict
d = defaultdict(set)
for i in open('/usr/share/dict/words'):
i = i.strip().lower()
if len(i) == 9:
d[tuple(sorted(i))].add(i)
for k,v in sorted(d.items(), key = lambda (k,v): (len(k), min(v))):
if len(v) > 2:
print '\t'.join(v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment