|
|
|
@ -12,27 +12,39 @@ def canidates(letters, min=2, max=5): |
|
|
|
for perm in itertools.permutations(comb): |
|
|
|
word = ''.join(perm) |
|
|
|
pos.append(word) |
|
|
|
return SPELL.known(pos) |
|
|
|
return set(SPELL.known(pos)) |
|
|
|
|
|
|
|
|
|
|
|
def filter_pos(pos, regex): |
|
|
|
pat = re.compile(regex + '$') |
|
|
|
return list(filter(pat.match, pos)) |
|
|
|
return set(filter(pat.match, pos)) |
|
|
|
|
|
|
|
|
|
|
|
while True: |
|
|
|
letters = input('Enter letters: ') |
|
|
|
if letters == ":quit:": |
|
|
|
break |
|
|
|
pos = canidates(letters) |
|
|
|
inp = None |
|
|
|
while inp not in (":quit:", ":new:"): |
|
|
|
if inp is not None: |
|
|
|
for word in filter_pos(pos, inp): |
|
|
|
print('>>>', word) |
|
|
|
print('Letters: ', ','.join(letters)) |
|
|
|
prompt = """Enter pattern, ':new:' for new letters, |
|
|
|
or ':quit:' to exit: """ |
|
|
|
inp = input(prompt) |
|
|
|
if inp == ":quit:": |
|
|
|
break |
|
|
|
if __name__ == "__main__": |
|
|
|
while True: |
|
|
|
letters = input('Enter letters: ') |
|
|
|
if letters == ":quit:": |
|
|
|
break |
|
|
|
pos = canidates(letters) |
|
|
|
inp = None |
|
|
|
guessed = set() |
|
|
|
while inp not in (":quit:", ":new:"): |
|
|
|
if inp == ":enter:": |
|
|
|
inp = None |
|
|
|
while inp != ":done:": |
|
|
|
if inp is not None: |
|
|
|
guessed.add(inp) |
|
|
|
inp = input("Enter guessed word, :done: to exit: ") |
|
|
|
elif inp is not None: |
|
|
|
fpos = filter_pos(pos, inp) |
|
|
|
for word in fpos-guessed: |
|
|
|
print('>>>', word) |
|
|
|
print('Letters: ', ','.join(letters)) |
|
|
|
prompt = """\ |
|
|
|
Enter pattern, |
|
|
|
':new:' for new letters, |
|
|
|
':enter:' to fill in guessed words, or |
|
|
|
':quit:' to exit: """ |
|
|
|
inp = input(prompt) |
|
|
|
if inp == ":quit:": |
|
|
|
break |