DEV Community

Discussion on: Daily Challenge #205 - Consonant String Value

Collapse
 
idanarye profile image
Idan Arye

Rust:

pub fn solve(text: &str) -> u32 {
    text.split(|c| match c {
        'a' | 'e' | 'i' | 'o' | 'u' => true,
        _ => false,
    }).map(|seq| {
        seq.chars().map(|c| (c as u32) - ('a' as u32) + 1u32).sum::<u32>()
    }).max().unwrap_or(0)
}