mirror of
https://gitlab.com/MisterBiggs/wordle-rs.git
synced 2025-09-19 12:12:37 +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 {
|
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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user