Skip to content

Instantly share code, notes, and snippets.

@maghoff
Created May 5, 2013 18:48
Show Gist options
  • Save maghoff/5521751 to your computer and use it in GitHub Desktop.
Save maghoff/5521751 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
words_file = "/usr/share/dict/words"
suffix = sys.argv[1]
candidates = set(w.strip()[:-len(suffix)] for w in open(words_file, 'rb') if w.strip().endswith(suffix))
words = [w.strip() for w in open(words_file, 'rb') if w.strip() in candidates]
print '\n'.join(words)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment