doku: write some documentation
This commit is contained in:
parent
75acd3ea09
commit
9ee13cc480
10
src/day03.rs
10
src/day03.rs
@ -18,12 +18,12 @@ fn solve_task01(content: &str) -> i32 {
|
||||
let vector = utils::convert_to_string_slice(&content);
|
||||
|
||||
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()
|
||||
.map(|x| x.chars().collect::<HashSet<_>>())
|
||||
.reduce(|acc, x| &acc & &x).unwrap())
|
||||
.map(|x| *x.iter().next().unwrap())
|
||||
.map(|c| convert_char_to_prio(c) as i32)
|
||||
.map(|x| x.chars().collect::<HashSet<_>>()) // remove duplicates per pack
|
||||
.reduce(|acc, x| &acc & &x).unwrap()) // filter for only duplicates in all packages
|
||||
.map(|x| *x.iter().next().unwrap()) // take first item in every set
|
||||
.map(|c| convert_char_to_prio(c) as i32) // convert character to number
|
||||
.sum()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user