This commit is contained in:
Simon Gardling
2022-03-28 20:05:21 -04:00
parent 345851d8b4
commit 6d57d96bb2
4 changed files with 25 additions and 12 deletions

View File

@@ -204,6 +204,23 @@ pub fn test_func(function_string: &str) -> Option<String> {
}
}
pub fn generate_hint(input: &str) -> String {
if input.is_empty() {
return "x^2".to_owned();
}
let chars: Vec<char> = input.chars().collect();
let open_parens = chars.iter().filter(|c| **c == '(').count();
let closed_parents = chars.iter().filter(|c| **c == ')').count();
if open_parens > closed_parents {
return ")".to_owned();
}
String::new()
}
#[cfg(test)]
mod tests {
use super::*;