const KEYBOARD_ROWS: [&str; 3] = [
"qwertyuiop",
"asdfghjkl",
"zxcvbnm",
];
pub fn find_keyboard_row(list: Vec<String>) -> Result<Vec<String>, String> {
if list.is_empty() {
return Err("Cannot verify if an empty list can be typed!".to_string());
}
let mut results: Vec<String> = vec![];
for word in list {
if KEYBOARD_ROWS.iter().any(|row| {word.chars().all(|c| row.contains(c))}) {
results.push(word);
}
}
if results.is_empty() {
return Err("None of the words specified can be typed!".to_string());
}
Ok(results)
}