From 1da7a12927f924bc30e2a08ca1fee708e4f82752 Mon Sep 17 00:00:00 2001 From: Andrew Coleman Date: Wed, 21 Feb 2024 12:59:51 -0500 Subject: [PATCH] cargo fmt --- 2023/src/bin/01.rs | 4 +++- 2023/src/bin/06.rs | 14 ++++++++------ 2023/src/bin/07.rs | 5 ++++- 2023/src/bin/09.rs | 18 ++++++++++++++++-- 2023/src/bin/19.rs | 1 - 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/2023/src/bin/01.rs b/2023/src/bin/01.rs index 702cd67..a5c0f75 100644 --- a/2023/src/bin/01.rs +++ b/2023/src/bin/01.rs @@ -107,7 +107,9 @@ mod tests { #[test] fn test_part_two() { - let result = part_two(&advent_of_code::template::read_file("examples", DAY, 2)); + let result = part_two(&advent_of_code::template::read_file_part( + "examples", DAY, 2, + )); assert_eq!(result, Some(281)); } } diff --git a/2023/src/bin/06.rs b/2023/src/bin/06.rs index c3022bc..0cbb8f4 100644 --- a/2023/src/bin/06.rs +++ b/2023/src/bin/06.rs @@ -39,12 +39,14 @@ fn parse(input: &str) -> Vec { } pub fn part_one(input: &str) -> Option { - Some(parse(input) - .iter() - .map(|race| race.winning_times().len() as u64) - .collect::>() - .iter() - .product()) + Some( + parse(input) + .iter() + .map(|race| race.winning_times().len() as u64) + .collect::>() + .iter() + .product(), + ) } pub fn part_two(input: &str) -> Option { diff --git a/2023/src/bin/07.rs b/2023/src/bin/07.rs index e49f6c4..0be042e 100644 --- a/2023/src/bin/07.rs +++ b/2023/src/bin/07.rs @@ -256,7 +256,10 @@ fn parse(input: &str) -> Vec { pub fn part_one(input: &str) -> Option { let mut sum: u64 = 0; - let mut hands = parse(input).iter().map(|h| h.clone()).collect::>(); + let mut hands = parse(input) + .iter() + .map(|h| h.clone()) + .collect::>(); hands.sort(); for (index, hand) in hands.iter().rev().enumerate() { sum += hand.bid * (index as u64 + 1); diff --git a/2023/src/bin/09.rs b/2023/src/bin/09.rs index f470b53..be5886e 100644 --- a/2023/src/bin/09.rs +++ b/2023/src/bin/09.rs @@ -38,7 +38,14 @@ fn next_number(s: &Seq) -> i32 { } pub fn part_one(input: &str) -> Option { - Some(parse(input).iter().map(|s| next_number(&s)).sum::().try_into().unwrap()) + Some( + parse(input) + .iter() + .map(|s| next_number(&s)) + .sum::() + .try_into() + .unwrap(), + ) } fn previous_number(s: &Seq) -> i32 { @@ -51,7 +58,14 @@ fn previous_number(s: &Seq) -> i32 { } pub fn part_two(input: &str) -> Option { - Some(parse(input).iter().map(|s| previous_number(&s)).sum::().try_into().unwrap()) + Some( + parse(input) + .iter() + .map(|s| previous_number(&s)) + .sum::() + .try_into() + .unwrap(), + ) } #[cfg(test)] diff --git a/2023/src/bin/19.rs b/2023/src/bin/19.rs index 5b67319..8fe2c6f 100644 --- a/2023/src/bin/19.rs +++ b/2023/src/bin/19.rs @@ -144,7 +144,6 @@ pub fn part_one(input: &str) -> Option { Some(parts.iter().map(|p| filter_part(&rules, &p)).sum()) } - fn combinations(weights: [(u64, u64); 4]) -> u64 { (0..4) .into_iter()