doku: write some documentation

This commit is contained in:
Lennard Brinkhaus 2022-12-07 02:36:08 +01:00
parent 75acd3ea09
commit 9ee13cc480
Signed by: lennard.brinkhaus
GPG Key ID: 286421EC53998B22

View File

@ -18,12 +18,12 @@ fn solve_task01(content: &str) -> i32 {
let vector = utils::convert_to_string_slice(&content); let vector = utils::convert_to_string_slice(&content);
vector.into_iter() vector.into_iter()
.map(|x| [&x[..x.len()/2], &x[x.len()/2..]] .map(|x| [&x[..x.len()/2], &x[x.len()/2..]] // create package to compare
.into_iter() .into_iter()
.map(|x| x.chars().collect::<HashSet<_>>()) .map(|x| x.chars().collect::<HashSet<_>>()) // remove duplicates per pack
.reduce(|acc, x| &acc & &x).unwrap()) .reduce(|acc, x| &acc & &x).unwrap()) // filter for only duplicates in all packages
.map(|x| *x.iter().next().unwrap()) .map(|x| *x.iter().next().unwrap()) // take first item in every set
.map(|c| convert_char_to_prio(c) as i32) .map(|c| convert_char_to_prio(c) as i32) // convert character to number
.sum() .sum()
} }