diff --git a/src/game/mod.rs b/src/game/mod.rs index 9e96fcd..4209df8 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -94,7 +94,7 @@ impl<'wl, WL: WordList> Game<'wl, WL> { for (idx, c) in guess.chars().enumerate() { if compare_solution.chars().nth(idx) == Some(c) { status = Status::Matched; - compare_solution = compare_solution.replace(c, "_"); + compare_solution.replace_range(idx..idx+1, "_"); } else if compare_solution.contains(c) { status = Status::Exists; compare_solution = compare_solution.replacen(c, "_", 1); diff --git a/src/solve/naive/mod.rs b/src/solve/naive/mod.rs index 7cddb33..655efcf 100644 --- a/src/solve/naive/mod.rs +++ b/src/solve/naive/mod.rs @@ -35,7 +35,9 @@ impl<'wl, WL: WordList> Solver<'wl, WL> for NaiveSolver<'wl, WL> { .get_words_matching(pattern) .expect("the solution does not exist in the wordlist") .iter() + // only words that have not been guessed yet .filter(|p| !game.made_guesses().contains(&&p.0)) + // only words that contain the letters we found earlier (that were not matched) .filter(|p| { // TODO: don't repeat unmatched contained chars on the same position twice #2 let mut fits = true;