Last active
June 15, 2016 23:28
-
-
Save noahp/25da97a744106e29fb0ac78ad0775383 to your computer and use it in GitHub Desktop.
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
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