From b2fa8774c3030c20416087c6b523c2a1896cd630 Mon Sep 17 00:00:00 2001 From: Anett Seeker Date: Mon, 20 Jun 2022 15:07:59 +0200 Subject: [PATCH] Remove guessed word from Wordlist in simulation --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 3c4b61c..070f445 100644 --- a/src/main.rs +++ b/src/main.rs @@ -192,10 +192,11 @@ fn simulate(start: &Word, target: &Word) -> Option { return Some(i); } + let w_string = w.to_string(); let color_code = w.match_code(target); debug!("Wordle hint: {}", color_code); - let constraints = ConstraintSet::try_from((w.to_string().as_ref(), color_code.as_ref())); + let constraints = ConstraintSet::try_from((w_string.as_ref(), color_code.as_ref())); if constraints.as_ref().unwrap().correct_word() { debug!("\nI won after {} round{}.", i, plural(i)); @@ -203,6 +204,7 @@ fn simulate(start: &Word, target: &Word) -> Option { } wordlist = Wordlist::from_iter(wordlist.filter(&constraints.unwrap())); + wordlist.remove(&w_string); if wordlist.len() > 1 && i == ROUND_NUM { debug!("\n{} candidate words left.", wordlist.len());