Skip to content

Instantly share code, notes, and snippets.

@marcinwyszynski
Created January 12, 2012 15:12
Show Gist options
  • Save marcinwyszynski/1601041 to your computer and use it in GitHub Desktop.
Save marcinwyszynski/1601041 to your computer and use it in GitHub Desktop.
Anagram finder for Unix-like systems
#!/usr/bin/env python
import sys
try:
word = sys.argv[1]
except IndexError:
print 'usage: anagrams.py <word>'
exit(1)
with open('/usr/share/dict/words', 'r') as fd:
for line in fd:
entry = line.rstrip()
if sorted(word.lower()) == sorted(entry.lower()) \
and not word.lower() == entry.lower():
print entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment