We're a place where coders share, stay up-to-date and grow their careers.
Rust Solution: Playground
fn solver(sentance: &str) -> String { sentance .to_ascii_lowercase() .replace("ie", "ei") .split_whitespace() .enumerate() .map(|(i, word)| { if i == 0 { let mut ch = word.chars(); match ch.next() { None => String::new(), Some(c) => c.to_uppercase().chain(ch).collect(), } } else { word.to_string() } }) .collect::<Vec<String>>() .join(" ") }
Rust Solution: Playground