mirror of
https://gitlab.com/MisterBiggs/wordle-rs.git
synced 2025-09-18 19:52:43 +00:00
improve checkclose
This commit is contained in:
@@ -52,12 +52,20 @@ fn check_exact(word: &String, exact: &str) -> bool {
|
||||
|
||||
fn check_close(word: &String, close: &Vec<(char, usize)>) -> bool {
|
||||
for (character, index) in close {
|
||||
// igore initialization value
|
||||
if *character == '.' {
|
||||
continue;
|
||||
}
|
||||
|
||||
// character cant be in the same index
|
||||
if *character == word.chars().nth(*index).unwrap() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// character must appear in word to be valid guess
|
||||
if !word.contains(*character) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user