loading...

re: Daily Challenge #191 - Alphabetical Addition VIEW POST

FULL DISCUSSION
 

Rust solution

fn add_letters(chars: Vec<char>) -> char {
    if chars.is_empty() {
        return 'z';
    }
    let a_num = 'a' as u32;
    std::char::from_u32((chars.iter().map(|&c| c as u32 - a_num + 1).sum::<u32>() % 26) + a_num - 1)
        .unwrap()
}
Code of Conduct Report abuse