From 05951ebc8acadc3a4fa139887367688c2717c2b0 Mon Sep 17 00:00:00 2001 From: Dylan Thies Date: Fri, 29 Dec 2023 13:34:59 -0500 Subject: [PATCH] clean ups --- 2023/Cargo.toml | 5 +++++ 2023/day-10/Cargo.toml | 2 +- 2023/day-17/Cargo.toml | 2 +- 2023/day-20/Cargo.toml | 2 +- 2023/day-23/Cargo.toml | 2 +- 2023/day-23/src/part1.rs | 7 +++++++ 2023/day-23/src/part2.rs | 20 +++++++++----------- 2023/day-24/Cargo.toml | 2 +- 2023/day-25/Cargo.toml | 4 ++-- 2023/day-7/Cargo.toml | 4 ++-- 10 files changed, 30 insertions(+), 20 deletions(-) diff --git a/2023/Cargo.toml b/2023/Cargo.toml index 58fbf08..2af1417 100644 --- a/2023/Cargo.toml +++ b/2023/Cargo.toml @@ -19,6 +19,11 @@ rstest = "0.18.2" rstest_reuse = "0.6.0" dhat = "0.3.2" glam = "0.24.2" +petgraph = "0.6.4" +num = "0.4.1" +num-traits = "0.2.17" +rustworkx-core = "0.13.2" +pathfinding = "4.6.0" [profile.dhat] diff --git a/2023/day-10/Cargo.toml b/2023/day-10/Cargo.toml index eb82395..6354e76 100644 --- a/2023/day-10/Cargo.toml +++ b/2023/day-10/Cargo.toml @@ -11,7 +11,7 @@ repository.workspace = true nom.workspace = true nom_locate = {workspace = true } itertools.workspace = true -glam = "0.24.2" +glam.workspace = true [dev-dependencies] rstest = {workspace = true} diff --git a/2023/day-17/Cargo.toml b/2023/day-17/Cargo.toml index 4404214..82e7620 100644 --- a/2023/day-17/Cargo.toml +++ b/2023/day-17/Cargo.toml @@ -12,7 +12,7 @@ nom = { workspace = true } itertools = {workspace = true } nom_locate.workspace = true glam.workspace = true -pathfinding = "4.6.0" +pathfinding.workspace = true [dev-dependencies] rstest.workspace = true diff --git a/2023/day-20/Cargo.toml b/2023/day-20/Cargo.toml index 38cfcb7..90b7e82 100644 --- a/2023/day-20/Cargo.toml +++ b/2023/day-20/Cargo.toml @@ -10,7 +10,7 @@ repository.workspace = true [dependencies] nom = { workspace = true } itertools = {workspace = true } -num = "0.4.1" +num.workspace = true [dev-dependencies] rstest.workspace = true diff --git a/2023/day-23/Cargo.toml b/2023/day-23/Cargo.toml index 2651baf..bceadd0 100644 --- a/2023/day-23/Cargo.toml +++ b/2023/day-23/Cargo.toml @@ -12,4 +12,4 @@ nom = { workspace = true } itertools = {workspace = true } glam.workspace = true nom_locate.workspace = true -petgraph = "0.6.4" +petgraph = {workspace = true} diff --git a/2023/day-23/src/part1.rs b/2023/day-23/src/part1.rs index a0a99c9..3b69ef8 100644 --- a/2023/day-23/src/part1.rs +++ b/2023/day-23/src/part1.rs @@ -26,6 +26,13 @@ impl PointType { } } +/// day 23 part 1 of aoc 2023 +/// +/// # Arguments +/// - input the input for today's puzzle +/// +/// # Panics +/// panics whne it cannot parse the input OR when ever the number of game numbers is greater than #[must_use] pub fn part1(input: &str) -> String { let maze = parse_input(input); diff --git a/2023/day-23/src/part2.rs b/2023/day-23/src/part2.rs index 82c1124..fe9c701 100644 --- a/2023/day-23/src/part2.rs +++ b/2023/day-23/src/part2.rs @@ -14,14 +14,13 @@ enum PointType { OnlyUp, } -impl PointType { - fn next_possibles(self) -> Vec { - match self { - _ => vec![IVec2::X, IVec2::Y, IVec2::NEG_X, IVec2::NEG_Y], - } - } -} - +/// day 23 part 2 of aoc 2023 +/// +/// # Arguments +/// - input the input for today's puzzle +/// +/// # Panics +/// panics whne it cannot parse the input OR when ever the number of game numbers is greater than #[must_use] pub fn part2(input: &str) -> String { let maze = parse_input(input); @@ -41,9 +40,8 @@ pub fn part2(input: &str) -> String { .collect::>(); maze.iter() - .flat_map(|(pos, point_type)| { - point_type - .next_possibles() + .flat_map(|(pos, _point_type)| { + [IVec2::X, IVec2::Y, IVec2::NEG_X, IVec2::NEG_Y] .iter() .copied() .filter_map(|dir| { diff --git a/2023/day-24/Cargo.toml b/2023/day-24/Cargo.toml index aa64035..4b62336 100644 --- a/2023/day-24/Cargo.toml +++ b/2023/day-24/Cargo.toml @@ -11,4 +11,4 @@ repository.workspace = true nom = { workspace = true } itertools = {workspace = true } glam.workspace = true -num = "0.4.1" +num.workspace = true diff --git a/2023/day-25/Cargo.toml b/2023/day-25/Cargo.toml index 35bef18..44d6378 100644 --- a/2023/day-25/Cargo.toml +++ b/2023/day-25/Cargo.toml @@ -10,5 +10,5 @@ repository.workspace = true [dependencies] nom = { workspace = true } itertools = {workspace = true } -petgraph = "0.6.4" -rustworkx-core = "0.13.2" +petgraph.workspace = true +rustworkx-core.workspace = true diff --git a/2023/day-7/Cargo.toml b/2023/day-7/Cargo.toml index f7b1dde..f893f90 100644 --- a/2023/day-7/Cargo.toml +++ b/2023/day-7/Cargo.toml @@ -10,8 +10,8 @@ repository.workspace = true [dependencies] nom.workspace = true itertools.workspace = true -num = "0.4.1" -num-traits = "0.2.17" +num.workspace = true +num-traits.workspace = true dhat = { workspace = true } [features]