From e7329ac91be253001bd8b70faece57103693799c Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Tue, 1 Nov 2022 22:51:34 -0700 Subject: [PATCH] This is slightly faster... --- examples/wordle/wordle.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/wordle/wordle.py b/examples/wordle/wordle.py index 52ef9b3..bf8dd36 100755 --- a/examples/wordle/wordle.py +++ b/examples/wordle/wordle.py @@ -655,11 +655,6 @@ class AutoPlayer(object): if letter in word_state.letters_excluded: return False - # If we already tried this letter in this position and - # it wasn't green, this isn't a possible solution. - if n in word_state.letters_at_unknown_positions[letter]: - return False - # If we know a letter is in a position, solution words # must have that letter in that position. if ( @@ -667,6 +662,12 @@ class AutoPlayer(object): and letter != word_state.letters_at_known_positions[n] ): return False + + # If we already tried this letter in this position and + # it wasn't green, this isn't a possible solution. + if n in word_state.letters_at_unknown_positions[letter]: + return False + letters_seen[letter] += 1 # Finally, the word must include all letters presently -- 2.46.0