From cdb1542184362747e9d70276ddb662d65d38335d Mon Sep 17 00:00:00 2001 From: Cameron Blankenbuehler Date: Wed, 7 Sep 2022 10:28:12 -0400 Subject: [PATCH] Fix bug loading duplicate wordlist for multi-letter blocks --- boggler_utils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/boggler_utils.py b/boggler_utils.py index 883a290..ea54abe 100644 --- a/boggler_utils.py +++ b/boggler_utils.py @@ -386,11 +386,15 @@ def build_full_boggle_tree(board: BoggleBoard, wordlist_path: str) -> dict[str, index = {} print("Reading in wordlists...") - for letter in alphabet: - filename = "words_" + letter[0] + ".txt" - print(f">> {letter}: {filename}") + for letters in alphabet: + if letters[0] in index: + index[letters] = index[letters[0]] + continue + + filename = "words_" + letters[0] + ".txt" + print(f">> {letters}: {filename}") wordlist = read_wordlist(path.join(path.abspath(wordlist_path), filename)) - index[letter] = wordlist + index[letters] = wordlist print("Generating WordTrees...") params = [ [alphabet, board, cell, index[cell.letters] ] for cell in board.board.values()]