From 5849744ce9c5da115eb2c34d8f9f9d01debff739 Mon Sep 17 00:00:00 2001 From: mishco Date: Fri, 13 Dec 2024 20:29:38 +0100 Subject: [PATCH] Updates and cleaning --- src/bin/05.rs | 48 +----------------------------------------------- 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/src/bin/05.rs b/src/bin/05.rs index 5aba6fc..c231fa5 100644 --- a/src/bin/05.rs +++ b/src/bin/05.rs @@ -27,29 +27,6 @@ pub fn part_one(input: &str) -> Option { .sum(); Some(result as u32) - - // let (s1, s2) = input.split_once("\n\n").unwrap(); - // let mut orderings = HashMap::>::new(); - // for l in s1.lines() { - // let (x, y) = l.split_once('|').unwrap(); - // orderings.entry(y.parse().unwrap()).or_default().insert(x.parse().unwrap()); - // } - // let pages = s2.lines().map(|l| { - // l.split(',').map(|w| w.parse::().unwrap()).collect::>() - // }); - // - // let (mut p1, mut p2) = (0, 0); - // for mut p in pages { - // if p.is_sorted_by(|a, b| orderings[b].contains(a)) { - // p1 += p[p.len() / 2]; - // } else { - // p.sort_by(|a, b| orderings[b].contains(a).cmp(&true)); - // p2 += p[p.len() / 2]; - // } - // } - // // (p1, p2) - // - // return Some(p1 as u32); } pub fn part_two(input: &str) -> Option { @@ -89,29 +66,6 @@ pub fn part_two(input: &str) -> Option { .sum(); Some(result as u32) - - // let (s1, s2) = input.split_once("\n\n").unwrap(); - // let mut orderings = HashMap::>::new(); - // for l in s1.lines() { - // let (x, y) = l.split_once('|').unwrap(); - // orderings.entry(y.parse().unwrap()).or_default().insert(x.parse().unwrap()); - // } - // let pages = s2.lines().map(|l| { - // l.split(',').map(|w| w.parse::().unwrap()).collect::>() - // }); - // - // let (mut p1, mut p2) = (0, 0); - // for mut p in pages { - // if p.is_sorted_by(|a, b| orderings[b].contains(a)) { - // p1 += p[p.len() / 2]; - // } else { - // p.sort_by(|a, b| orderings[b].contains(a).cmp(&true)); - // p2 += p[p.len() / 2]; - // } - // } - // // (p1, p2) - // - // return Some(p2 as u32); } #[cfg(test)] @@ -127,6 +81,6 @@ mod tests { #[test] fn test_part_two() { let result = part_two(&advent_of_code::template::read_file("examples", DAY)); - assert_eq!(result, None); + assert_eq!(result, Some(123)); } }