This is slightly faster...
[pyutils.git] / examples / wordle / wordle.py
index df9874ee0b309e7a70a5a7c8900629869def3928..bf8dd36ee1d2265eb6b0a428ba15e00425ba6440 100755 (executable)
@@ -24,7 +24,7 @@ from pyutils.files import file_utils
 from pyutils.parallelize import executors
 from pyutils.parallelize import parallelize as par
 from pyutils.parallelize import smart_future
-from pyutils.typez import histogram
+from pyutils.types import histogram
 
 logger = logging.getLogger(__name__)
 args = config.add_commandline_args(
@@ -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