Created
January 12, 2012 15:12
-
-
Save marcinwyszynski/1601041 to your computer and use it in GitHub Desktop.
Anagram finder for Unix-like systems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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