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);
|
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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user