Skip to content

Instantly share code, notes, and snippets.

@noahp
Last active June 15, 2016 23:28
Show Gist options
  • Save noahp/25da97a744106e29fb0ac78ad0775383 to your computer and use it in GitHub Desktop.
Save noahp/25da97a744106e29fb0ac78ad0775383 to your computer and use it in GitHub Desktop.
import itertools
import enchant
import sys
def getwords(letters, len):
words = []
d = enchant.Dict("en_US")
for w in [''.join(x) for x in itertools.permutations(letters, len)]:
if d.check(w):
words.append(w)
return words
if __name__ == '__main__':
print '\n'.join(getwords(sys.argv[1], int(sys.argv[2])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment