You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
10 lines
381 B
10 lines
381 B
use std::collections::BTreeMap; |
|
|
|
pub fn transform(h: &BTreeMap<i32, Vec<char>>) -> BTreeMap<char, i32> { |
|
h.into_iter() |
|
.flat_map(|(value, letters)| letters.iter().map(move |l| (l.to_lowercase(), value))) |
|
.fold(BTreeMap::new(), |mut acc, (letter, value)| { |
|
acc.insert(letter.to_string().chars().nth(0).unwrap(), *value); |
|
acc |
|
}) |
|
}
|
|
|