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(
args.add_argument(
'--solutions_file',
type=str,
- default='/home/scott/bin/wordle_solutions.txt',
+ default='wordle_solutions.txt',
help='Where can I find a valid word list for solutions?',
)
args.add_argument(
'--guesses_file',
type=str,
- default='/home/scott/bin/wordle_guesses.txt',
+ default='wordle_guesses.txt',
help='Where can I find a valid word list for guesses?',
)
args.add_argument(
'--hash_file',
type=str,
- default='/home/scott/bin/wordle_hash.txt',
+ default='wordle_hash.txt',
help='Where can I find my precomputed hash file?',
)
# remaining words. See --mode=PRECOMPUTE for how to populate.
self.position_hash = {}
filename = config.config['hash_file']
- if filename is not None and file_utils.file_is_readable(filename):
+ if filename is not None and file_utils.is_readable(filename):
logger.debug(f'Initializing position hash from {filename}...')
with open(filename, 'r') as rf:
for line in rf:
# All legal solutions pre-sorted by length.
self.all_possible_solutions_by_length = defaultdict(list)
filename = config.config['solutions_file']
- if filename is not None and file_utils.file_is_readable(filename):
+ if filename is not None and file_utils.is_readable(filename):
logger.debug(f'Initializing valid solution word list from {filename}...')
with open(filename) as rf:
for word in rf:
# All legal guesses pre-sorted by length.
self.all_possible_guesses_by_length = defaultdict(list)
filename = config.config['guesses_file']
- if filename is not None and file_utils.file_is_readable(filename):
+ if filename is not None and file_utils.is_readable(filename):
logger.debug(f'Initializing legal guess word list from {filename}...')
with open(filename) as rf:
for word in rf:
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 (
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
def get_max_letter_population() -> Dict[Letter, int]:
filename = config.config['solutions_file']
max_letter_population_per_word: Dict[Letter, int] = defaultdict(int)
- if filename is not None and file_utils.file_is_readable(filename):
+ if filename is not None and file_utils.is_readable(filename):
logger.debug(
'Figuring out all letters\' max frequency in the solution space...'
)