Skip to content

Commit

Permalink
Remove guessed word from Wordlist in simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
noeddl committed Jun 20, 2022
1 parent 467f41b commit b2fa877
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,19 @@ fn simulate(start: &Word, target: &Word) -> Option<usize> {
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));
return Some(i);
}

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());
Expand Down

0 comments on commit b2fa877

Please sign in to comment.