Created
October 28, 2018 03:16
-
-
Save rsmahmud/7abff3ea421b3c58e551b4a76eb261b0 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
#pip pyenchant | |
import enchant, itertools | |
characters = input("Enter the letters : ") | |
min_length = int(input("Enter min length : ")) | |
max_length = int(input("Enter max length : ")) | |
print() | |
D = enchant.Dict("en_US") | |
words = set() | |
for n in range(min_length, max_length + 1): | |
i = 0 | |
for xs in itertools.product(characters,repeat=n): | |
word = ''.join(xs) | |
if D.check(word): | |
print(word, end = ' ') | |
words.add(word) | |
i += 1 | |
if not i%5: | |
print() | |
print() | |
cmd = input("Continue to filter? <yes/no> :") | |
while(cmd is None or cmd != 'no'): | |
positions = list(map(int,input("Correct Position index [0 2 3] : ").split())) | |
letters = input("Letters at those index [a e d] : ") | |
if len(positions) != len(letters): | |
print("INVALID. Provide Space Separated List.") | |
break | |
for word in words: | |
i = 0 | |
for i in range(len(positions)): | |
if word[positions[i]] == letters[i]: | |
print(word, end = ' ') | |
i += 1 | |
if not i%3: | |
print() | |
cmd = input("Continue to filter? <yes/no> :") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment