From 9ee13cc480ecd227cf7c3af4acad184b7be0b441 Mon Sep 17 00:00:00 2001 From: Lennard Brinkhaus Date: Wed, 7 Dec 2022 02:36:08 +0100 Subject: [PATCH] doku: write some documentation --- src/day03.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/day03.rs b/src/day03.rs index 28b0cce..642b9f9 100644 --- a/src/day03.rs +++ b/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::>()) - .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::>()) // 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() }