Skip to content

Instantly share code, notes, and snippets.

@maghoff
Created May 5, 2013 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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