play_solve
This commit is contained in:
parent
387fd7f2f0
commit
18e9c6a151
11
play.py
11
play.py
@ -22,6 +22,12 @@ def build_letter_hint(guess, word):
|
||||
word_break[first_index] = BLANK
|
||||
return ''.join(letters_hints)
|
||||
|
||||
def build_non_letter_hint(guess, word):
|
||||
non_letters_hints = ''
|
||||
for letter in guess:
|
||||
if letter not in word and letter not in non_letters_hints:
|
||||
non_letters_hints += letter
|
||||
return non_letters_hints
|
||||
|
||||
def main_loop():
|
||||
word = random.choice([w for w in cat_words()])
|
||||
@ -31,10 +37,7 @@ def main_loop():
|
||||
guess = input("Guess: ")
|
||||
if len(guess) != 5 and not all([x.islower() for x in guess]):
|
||||
print("ERROR: {}".format(PLAY_INSTRUCTIONS))
|
||||
non_letters_hints = ''
|
||||
for letter in guess:
|
||||
if letter not in word and letter not in non_letters_hints:
|
||||
non_letters_hints += letter
|
||||
non_letters_hints = build_non_letter_hint(guess, word)
|
||||
letters_hints = build_letter_hint(guess, word)
|
||||
print("Non-letters: {}".format(non_letters_hints))
|
||||
print("Letters: {}".format(letters_hints))
|
||||
|
1
solve.py
1
solve.py
@ -147,6 +147,7 @@ def test():
|
||||
assert [w for w in round_words('', ['----y'], ['y----'], dictionary=['slyly'])] == ['slyly']
|
||||
assert [w for w in round_words('', ['---yy'], ['y----'], dictionary=['slyyy'])] == ['slyyy']
|
||||
assert [w for w in round_words('', ['---yy'], ['-----'], dictionary=['slyyy'])] == ['slyyy']
|
||||
assert [w for w in round_words('', ['-y---'], ['--y--'], dictionary=['sysys'])] == ['sysys']
|
||||
|
||||
|
||||
def main():
|
||||
|
Loading…
Reference in New Issue
Block a user