1
0
mirror of https://gitlab.com/MisterBiggs/wordle-rs.git synced 2025-09-19 04:02:48 +00:00

improve checkclose

This commit is contained in:
2022-02-09 15:41:29 -07:00
parent 5b87589478
commit b0dbf8354e

View File

@@ -52,12 +52,20 @@ fn check_exact(word: &String, exact: &str) -> bool {
fn check_close(word: &String, close: &Vec<(char, usize)>) -> bool { fn check_close(word: &String, close: &Vec<(char, usize)>) -> bool {
for (character, index) in close { for (character, index) in close {
// igore initialization value
if *character == '.' { if *character == '.' {
continue; continue;
} }
// character cant be in the same index
if *character == word.chars().nth(*index).unwrap() { if *character == word.chars().nth(*index).unwrap() {
return false; return false;
} }
// character must appear in word to be valid guess
if !word.contains(*character) {
return false;
}
} }
return true; return true;
} }