implemented way better anilist tracking

This commit is contained in:
Zastian Pretorius
2022-10-11 02:01:53 +01:00
parent c63bb81f40
commit 8ad12ebcca
6 changed files with 69 additions and 32 deletions

View File

@@ -1,2 +1,3 @@
pub mod fixing_text;
pub mod name_ranker;
pub mod take_input;

View File

@@ -0,0 +1,20 @@
pub fn string_sumularity_ranker(animixplay: Vec<&str>, gogo: &str) -> (usize, String) {
let mut score = 0;
let mut index = 0;
for a in &animixplay {
let mut temp_score = 0;
// compare the each first letter of the strings and then the second and so on without unwrapping
for (_i, (a, b)) in a.chars().zip(gogo.chars()).enumerate() {
if a == b {
temp_score += 1;
} else {
break;
}
}
if temp_score > score {
score = temp_score;
index = animixplay.iter().position(|&x| &x == a).unwrap();
}
}
(index, gogo.to_string()) //
}