Skip to content

Instantly share code, notes, and snippets.

@tkaemming
Created April 13, 2010 03:18
Show Gist options
  • Save tkaemming/364275 to your computer and use it in GitHub Desktop.
Save tkaemming/364275 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2.6
def find_anagrams(input_word):
words = (word[:-1] for word in open('/usr/share/dict/words').readlines())
return [word for word in words if (sorted(word) == sorted(input_word) and word != input_word)]
if __name__ == '__main__':
import sys
print find_anagrams(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment