From ad8351e09e7a1d1d90b98fc1f12b5dbbf36c34f5 Mon Sep 17 00:00:00 2001 From: Connor Slade Date: Mon, 25 Nov 2024 18:14:45 -0500 Subject: [PATCH] Dont include year in solution macro --- aoc_2021/src/day_01.rs | 2 +- aoc_2021/src/day_02.rs | 2 +- aoc_2021/src/day_03.rs | 2 +- aoc_2021/src/day_04.rs | 8 ++++---- aoc_2021/src/day_05.rs | 2 +- aoc_2021/src/day_06.rs | 2 +- aoc_2021/src/day_07.rs | 2 +- aoc_2021/src/day_08.rs | 2 +- aoc_2021/src/day_09.rs | 2 +- aoc_2021/src/day_10.rs | 2 +- aoc_2021/src/day_11.rs | 2 +- aoc_2021/src/day_12.rs | 2 +- aoc_2021/src/day_13.rs | 2 +- aoc_2021/src/day_14.rs | 2 +- aoc_2021/src/day_15.rs | 2 +- aoc_2022/src/day_01.rs | 2 +- aoc_2022/src/day_02.rs | 2 +- aoc_2022/src/day_03.rs | 12 ++++++------ aoc_2022/src/day_04.rs | 2 +- aoc_2022/src/day_05.rs | 2 +- aoc_2022/src/day_06.rs | 2 +- aoc_2022/src/day_07.rs | 2 +- aoc_2022/src/day_08.rs | 2 +- aoc_2022/src/day_09.rs | 2 +- aoc_2022/src/day_10.rs | 2 +- aoc_2022/src/day_11.rs | 2 +- aoc_2022/src/day_12.rs | 2 +- aoc_2022/src/day_13.rs | 2 +- aoc_2022/src/day_14.rs | 4 ++-- aoc_2022/src/day_15.rs | 4 ++-- aoc_2022/src/day_16.rs | 2 +- aoc_2022/src/day_17.rs | 4 ++-- aoc_2022/src/day_18.rs | 4 ++-- aoc_2022/src/day_19.rs | 2 +- aoc_2022/src/day_20.rs | 2 +- aoc_2022/src/day_21.rs | 2 +- aoc_2022/src/day_22.rs | 4 ++-- aoc_2022/src/day_23.rs | 4 ++-- aoc_2022/src/day_24.rs | 4 ++-- aoc_2022/src/day_25.rs | 2 +- aoc_2023/src/day_01.rs | 2 +- aoc_2023/src/day_02.rs | 12 +++--------- aoc_2023/src/day_03.rs | 2 +- aoc_2023/src/day_04.rs | 2 +- aoc_2023/src/day_05.rs | 2 +- aoc_2023/src/day_06.rs | 2 +- aoc_2023/src/day_07.rs | 2 +- aoc_2023/src/day_08.rs | 2 +- aoc_2023/src/day_09.rs | 2 +- aoc_2023/src/day_10.rs | 2 +- aoc_2023/src/day_11.rs | 2 +- aoc_2023/src/day_12.rs | 2 +- aoc_2023/src/day_13.rs | 2 +- aoc_2023/src/day_14.rs | 2 +- aoc_2023/src/day_15.rs | 2 +- aoc_2023/src/day_16.rs | 4 ++-- aoc_2023/src/day_17.rs | 4 ++-- aoc_2023/src/day_18.rs | 2 +- aoc_2023/src/day_19.rs | 2 +- aoc_2023/src/day_20.rs | 2 +- aoc_2023/src/day_21.rs | 2 +- aoc_2023/src/day_22.rs | 2 +- aoc_2023/src/day_23.rs | 4 ++-- aoc_2023/src/day_24.rs | 2 +- aoc_2023/src/day_25.rs | 2 +- common/src/lib.rs | 2 +- common/src/solution.rs | 36 +++--------------------------------- src/commands/list.rs | 2 +- src/commands/run.rs | 2 +- 69 files changed, 91 insertions(+), 127 deletions(-) diff --git a/aoc_2021/src/day_01.rs b/aoc_2021/src/day_01.rs index 2c3fe37..52cc23b 100644 --- a/aoc_2021/src/day_01.rs +++ b/aoc_2021/src/day_01.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Sonar Sweep", (2022, 00)); +solution!("Sonar Sweep", 1); fn part_a(input: &str) -> Answer { let data = input diff --git a/aoc_2021/src/day_02.rs b/aoc_2021/src/day_02.rs index 7f4d82b..b21f868 100644 --- a/aoc_2021/src/day_02.rs +++ b/aoc_2021/src/day_02.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Dive!", (2022, 00)); +solution!("Dive!", 2); fn part_a(input: &str) -> Answer { let mut dep: u32 = 0; diff --git a/aoc_2021/src/day_03.rs b/aoc_2021/src/day_03.rs index 272eb2e..4eec88d 100644 --- a/aoc_2021/src/day_03.rs +++ b/aoc_2021/src/day_03.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Binary Diagnostic", (2022, 00)); +solution!("Binary Diagnostic", 3); fn part_a(input: &str) -> Answer { let num_len = input.lines().next().unwrap().len(); diff --git a/aoc_2021/src/day_04.rs b/aoc_2021/src/day_04.rs index 10ce3ba..f742598 100644 --- a/aoc_2021/src/day_04.rs +++ b/aoc_2021/src/day_04.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Giant Squid", (2022, 00)); +solution!("Giant Squid", 4); fn part_a(input: &str) -> Answer { let bingo = Bingo::parse_input(input); @@ -11,9 +11,9 @@ fn part_a(input: &str) -> Answer { fn part_b(input: &str) -> Answer { let bingo = Bingo::parse_input(input); - let loseing = bingo.loseing_solve(); + let losing = bingo.losing_solve(); - loseing.0[loseing.1].final_out(loseing.2).into() + losing.0[losing.1].final_out(losing.2).into() } #[derive(Debug, Clone)] @@ -67,7 +67,7 @@ impl Bingo { } } - fn loseing_solve(self) -> (Vec, usize, u32) { + fn losing_solve(self) -> (Vec, usize, u32) { let mut nums = self.numbers.clone(); let mut tick = self.boards; let mut take = self.take; diff --git a/aoc_2021/src/day_05.rs b/aoc_2021/src/day_05.rs index 00e5bf8..aefef5d 100644 --- a/aoc_2021/src/day_05.rs +++ b/aoc_2021/src/day_05.rs @@ -2,7 +2,7 @@ use common::{solution, Answer}; use hashbrown::HashMap; -solution!("Hydrothermal Venture", (2022, 00)); +solution!("Hydrothermal Venture", 5); fn part_a(input: &str) -> Answer { run(input, false).into() diff --git a/aoc_2021/src/day_06.rs b/aoc_2021/src/day_06.rs index 3d3f505..c588fb2 100644 --- a/aoc_2021/src/day_06.rs +++ b/aoc_2021/src/day_06.rs @@ -4,7 +4,7 @@ use std::hash::Hash; use hashbrown::HashMap; -solution!("Lanternfish", (2022, 00)); +solution!("Lanternfish", 6); fn part_a(input: &str) -> Answer { let data = Fish::parse_inp(input); diff --git a/aoc_2021/src/day_07.rs b/aoc_2021/src/day_07.rs index 3041501..a40f55a 100644 --- a/aoc_2021/src/day_07.rs +++ b/aoc_2021/src/day_07.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("The Treachery of Whales", (2022, 00)); +solution!("The Treachery of Whales", 7); fn part_a(input: &str) -> Answer { let data = parse_crabs(input); diff --git a/aoc_2021/src/day_08.rs b/aoc_2021/src/day_08.rs index 92ebdf9..ed05228 100644 --- a/aoc_2021/src/day_08.rs +++ b/aoc_2021/src/day_08.rs @@ -8,7 +8,7 @@ const DIGITS: [&str; 10] = [ "abcefg", "cf", "acdeg", "acdfg", "bcdf", "abdfg", "abdefg", "acf", "abcdefg", "abcdfg", ]; -solution!("Seven Segment Search", (2022, 00)); +solution!("Seven Segment Search", 8); fn part_a(input: &str) -> Answer { let data = parse(input); diff --git a/aoc_2021/src/day_09.rs b/aoc_2021/src/day_09.rs index 934088c..8114fb8 100644 --- a/aoc_2021/src/day_09.rs +++ b/aoc_2021/src/day_09.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Smoke Basin", (2022, 00)); +solution!("Smoke Basin", 9); fn part_a(input: &str) -> Answer { let data = parse(input); diff --git a/aoc_2021/src/day_10.rs b/aoc_2021/src/day_10.rs index a115516..19a5422 100644 --- a/aoc_2021/src/day_10.rs +++ b/aoc_2021/src/day_10.rs @@ -2,7 +2,7 @@ use common::{solution, Answer}; const CHARS: [(char, char); 4] = [('(', ')'), ('[', ']'), ('{', '}'), ('<', '>')]; -solution!("Syntax Scoring", (2022, 00)); +solution!("Syntax Scoring", 10); fn part_a(input: &str) -> Answer { let data = parse(input); diff --git a/aoc_2021/src/day_11.rs b/aoc_2021/src/day_11.rs index dfe2941..f83fe0e 100644 --- a/aoc_2021/src/day_11.rs +++ b/aoc_2021/src/day_11.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Dumbo Octopus", (2022, 00)); +solution!("Dumbo Octopus", 11); fn part_a(input: &str) -> Answer { let mut octopi = parse(input); diff --git a/aoc_2021/src/day_12.rs b/aoc_2021/src/day_12.rs index 4656a85..ee14e97 100644 --- a/aoc_2021/src/day_12.rs +++ b/aoc_2021/src/day_12.rs @@ -2,7 +2,7 @@ use common::{solution, Answer}; use hashbrown::{HashMap, HashSet}; use petgraph::graph::{NodeIndex, UnGraph}; -solution!("Passage Pathing", (2022, 00)); +solution!("Passage Pathing", 12); fn part_a(input: &str) -> Answer { let graph = parse(input); diff --git a/aoc_2021/src/day_13.rs b/aoc_2021/src/day_13.rs index cfcc3d4..da0863a 100644 --- a/aoc_2021/src/day_13.rs +++ b/aoc_2021/src/day_13.rs @@ -5,7 +5,7 @@ use nd_vec::vector; type Point = nd_vec::Vec2; -solution!("Transparent Origami", (2022, 00)); +solution!("Transparent Origami", 13); fn part_a(input: &str) -> Answer { let mut paper = Paper::parse(input); diff --git a/aoc_2021/src/day_14.rs b/aoc_2021/src/day_14.rs index 0c0a1a3..9d3244b 100644 --- a/aoc_2021/src/day_14.rs +++ b/aoc_2021/src/day_14.rs @@ -2,7 +2,7 @@ use hashbrown::HashMap; use common::{solution, Answer}; -solution!("Extended Polymerization", (2022, 00)); +solution!("Extended Polymerization", 14); fn part_a(input: &str) -> Answer { process(input, 10).into() diff --git a/aoc_2021/src/day_15.rs b/aoc_2021/src/day_15.rs index eca1d7c..af6979b 100644 --- a/aoc_2021/src/day_15.rs +++ b/aoc_2021/src/day_15.rs @@ -3,7 +3,7 @@ use common::{solution, Answer}; use hashbrown::HashMap; use nd_vec::vector; -solution!("Chiton", (2022, 00)); +solution!("Chiton", 15); fn part_a(input: &str) -> Answer { let matrix = Matrix::new_chars(input, |chr| chr.to_digit(10).unwrap() as u8); diff --git a/aoc_2022/src/day_01.rs b/aoc_2022/src/day_01.rs index 7e81809..1a01d69 100644 --- a/aoc_2022/src/day_01.rs +++ b/aoc_2022/src/day_01.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Calorie Counting", (2022, 00)); +solution!("Calorie Counting", 1); fn part_a(input: &str) -> Answer { let elfs = get_elfs(input); diff --git a/aoc_2022/src/day_02.rs b/aoc_2022/src/day_02.rs index 000c41a..b78ec2a 100644 --- a/aoc_2022/src/day_02.rs +++ b/aoc_2022/src/day_02.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Rock Paper Scissors", (2022, 00)); +solution!("Rock Paper Scissors", 2); fn part_a(input: &str) -> Answer { let mut score = 0; diff --git a/aoc_2022/src/day_03.rs b/aoc_2022/src/day_03.rs index 98569ff..2bc34f4 100644 --- a/aoc_2022/src/day_03.rs +++ b/aoc_2022/src/day_03.rs @@ -2,19 +2,19 @@ use hashbrown::HashSet; use common::{solution, Answer}; -solution!("Rucksack Reorganization", (2022, 00)); +solution!("Rucksack Reorganization", 3); fn part_a(input: &str) -> Answer { let mut out = 0; for i in input.trim().lines() { - let mut bolth = i[0..i.len() / 2].chars().collect::>(); + let mut both = i[0..i.len() / 2].chars().collect::>(); let pocket_2 = i[i.len() / 2..].chars().collect::>(); - bolth.retain(|x| pocket_2.contains(x)); - bolth.dedup(); + both.retain(|x| pocket_2.contains(x)); + both.dedup(); - debug_assert!(bolth.len() == 1); - out += score_item(bolth[0]) as usize; + debug_assert!(both.len() == 1); + out += score_item(both[0]) as usize; } out.into() diff --git a/aoc_2022/src/day_04.rs b/aoc_2022/src/day_04.rs index af237b5..efe47cc 100644 --- a/aoc_2022/src/day_04.rs +++ b/aoc_2022/src/day_04.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Camp Cleanup", (2022, 00)); +solution!("Camp Cleanup", 4); fn part_a(input: &str) -> Answer { let mut out = 0; diff --git a/aoc_2022/src/day_05.rs b/aoc_2022/src/day_05.rs index d526f9f..8e557dd 100644 --- a/aoc_2022/src/day_05.rs +++ b/aoc_2022/src/day_05.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Supply Stacks", (2022, 00)); +solution!("Supply Stacks", 5); fn part_a(input: &str) -> Answer { process(input, true).into() diff --git a/aoc_2022/src/day_06.rs b/aoc_2022/src/day_06.rs index 9a45e3e..15aaa90 100644 --- a/aoc_2022/src/day_06.rs +++ b/aoc_2022/src/day_06.rs @@ -2,7 +2,7 @@ use hashbrown::HashSet; use common::{solution, Answer}; -solution!("Tuning Trouble", (2022, 00)); +solution!("Tuning Trouble", 6); fn part_a(input: &str) -> Answer { process(input, 4).into() diff --git a/aoc_2022/src/day_07.rs b/aoc_2022/src/day_07.rs index cd45fd0..bd18d90 100644 --- a/aoc_2022/src/day_07.rs +++ b/aoc_2022/src/day_07.rs @@ -2,7 +2,7 @@ use hashbrown::HashSet; use common::{solution, Answer}; -solution!("No Space Left On Device", (2022, 00)); +solution!("No Space Left On Device", 7); fn part_a(input: &str) -> Answer { process(input) diff --git a/aoc_2022/src/day_08.rs b/aoc_2022/src/day_08.rs index 49c72ef..7a40a37 100644 --- a/aoc_2022/src/day_08.rs +++ b/aoc_2022/src/day_08.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Treetop Tree House", (2022, 00)); +solution!("Treetop Tree House", 8); fn part_a(input: &str) -> Answer { let trees = parse_trees(input); diff --git a/aoc_2022/src/day_09.rs b/aoc_2022/src/day_09.rs index e446872..7951db1 100644 --- a/aoc_2022/src/day_09.rs +++ b/aoc_2022/src/day_09.rs @@ -7,7 +7,7 @@ use nd_vec::vector; type Point = nd_vec::Vec2; -solution!("Rope Bridge", (2022, 00)); +solution!("Rope Bridge", 9); fn part_a(input: &str) -> Answer { process(input, 1).into() diff --git a/aoc_2022/src/day_10.rs b/aoc_2022/src/day_10.rs index 4aea508..3517a80 100644 --- a/aoc_2022/src/day_10.rs +++ b/aoc_2022/src/day_10.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Cathode-Ray Tube", (2022, 00)); +solution!("Cathode-Ray Tube", 10); fn part_a(input: &str) -> Answer { let instructions = parse(input); diff --git a/aoc_2022/src/day_11.rs b/aoc_2022/src/day_11.rs index e098ed4..4d86542 100644 --- a/aoc_2022/src/day_11.rs +++ b/aoc_2022/src/day_11.rs @@ -2,7 +2,7 @@ use std::collections::VecDeque; use common::{solution, Answer}; -solution!("Monkey in the Middle", (2022, 00)); +solution!("Monkey in the Middle", 11); fn part_a(input: &str) -> Answer { let monkeys = parse_monkeys(input); diff --git a/aoc_2022/src/day_12.rs b/aoc_2022/src/day_12.rs index ab725b1..eb3dd78 100644 --- a/aoc_2022/src/day_12.rs +++ b/aoc_2022/src/day_12.rs @@ -5,7 +5,7 @@ use nd_vec::vector; type Point = nd_vec::Vec2; -solution!("Hill Climbing Algorithm", (2022, 00)); +solution!("Hill Climbing Algorithm", 12); fn part_a(input: &str) -> Answer { let map = parse(input); diff --git a/aoc_2022/src/day_13.rs b/aoc_2022/src/day_13.rs index ad4e5fe..7a26435 100644 --- a/aoc_2022/src/day_13.rs +++ b/aoc_2022/src/day_13.rs @@ -2,7 +2,7 @@ use std::cmp::Ordering; use common::{solution, Answer}; -solution!("Distress Signal", (2022, 00)); +solution!("Distress Signal", 13); fn part_a(input: &str) -> Answer { let signals = parse(input); diff --git a/aoc_2022/src/day_14.rs b/aoc_2022/src/day_14.rs index 46d94d2..9ac87f5 100644 --- a/aoc_2022/src/day_14.rs +++ b/aoc_2022/src/day_14.rs @@ -1,12 +1,12 @@ use common::{solution, Answer}; use nd_vec::vector; +solution!("Regolith Reservoir", 14); + type Point = nd_vec::Vec2; const NEW_POINT: Point = vector!(500, 0); -solution!("Regolith Reservoir", (2022, 00)); - fn part_a(input: &str) -> Answer { let mut world = World::parse(input); diff --git a/aoc_2022/src/day_15.rs b/aoc_2022/src/day_15.rs index dae1f10..22e011e 100644 --- a/aoc_2022/src/day_15.rs +++ b/aoc_2022/src/day_15.rs @@ -3,9 +3,9 @@ use common::{solution, Answer}; use nd_vec::vector; use rayon::prelude::*; -type Point = nd_vec::Vec2; +solution!("Beacon Exclusion Zone", 15); -solution!("Beacon Exclusion Zone", (2022, 00)); +type Point = nd_vec::Vec2; fn part_a(input: &str) -> Answer { let world = World::parse(input); diff --git a/aoc_2022/src/day_16.rs b/aoc_2022/src/day_16.rs index 8640310..655e2ea 100644 --- a/aoc_2022/src/day_16.rs +++ b/aoc_2022/src/day_16.rs @@ -4,7 +4,7 @@ use common::{solution, Answer}; use hashbrown::HashMap; -solution!("Proboscidea Volcanium", (2022, 00)); +solution!("Proboscidea Volcanium", 16); fn part_a(input: &str) -> Answer { let parse = parse(input); diff --git a/aoc_2022/src/day_17.rs b/aoc_2022/src/day_17.rs index eb6986e..0cc0231 100644 --- a/aoc_2022/src/day_17.rs +++ b/aoc_2022/src/day_17.rs @@ -3,9 +3,9 @@ use hashbrown::{hash_map::Entry, HashMap}; use common::{solution, Answer}; use nd_vec::vector; -type Point = nd_vec::Vec2; +solution!("Pyroclastic Flow", 17); -solution!("Pyroclastic Flow", (2022, 00)); +type Point = nd_vec::Vec2; fn part_a(input: &str) -> Answer { let mut world = World::new(input); diff --git a/aoc_2022/src/day_18.rs b/aoc_2022/src/day_18.rs index 6f0c45a..5abc33b 100644 --- a/aoc_2022/src/day_18.rs +++ b/aoc_2022/src/day_18.rs @@ -3,9 +3,9 @@ use hashbrown::HashSet; use common::{solution, Answer}; use nd_vec::{vector, Vector}; -type Pos = nd_vec::Vec3; +solution!("Boiling Boulders", 18); -solution!("Boiling Boulders", (2022, 00)); +type Pos = nd_vec::Vec3; fn part_a(input: &str) -> Answer { let world = World::parse(input); diff --git a/aoc_2022/src/day_19.rs b/aoc_2022/src/day_19.rs index 86210c7..7c1bbcb 100644 --- a/aoc_2022/src/day_19.rs +++ b/aoc_2022/src/day_19.rs @@ -1,7 +1,7 @@ use common::{solution, Answer}; use hashbrown::HashMap; -solution!("Not Enough Minerals ", (2022, 00)); +solution!("Not Enough Minerals", 19); fn part_a(input: &str) -> Answer { let robots = parse(input); diff --git a/aoc_2022/src/day_20.rs b/aoc_2022/src/day_20.rs index 0f70be2..eb18369 100644 --- a/aoc_2022/src/day_20.rs +++ b/aoc_2022/src/day_20.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Grove Positioning System", (2022, 00)); +solution!("Grove Positioning System", 20); fn part_a(input: &str) -> Answer { let mut file = File::new(input); diff --git a/aoc_2022/src/day_21.rs b/aoc_2022/src/day_21.rs index c9c50cb..c5f38b2 100644 --- a/aoc_2022/src/day_21.rs +++ b/aoc_2022/src/day_21.rs @@ -2,7 +2,7 @@ use hashbrown::HashMap; use common::{solution, Answer}; -solution!("Monkey Math", (2022, 00)); +solution!("Monkey Math", 21); fn part_a(input: &str) -> Answer { let monkeys = MonkeyBusiness::new(input); diff --git a/aoc_2022/src/day_22.rs b/aoc_2022/src/day_22.rs index 71ae41e..4853b19 100644 --- a/aoc_2022/src/day_22.rs +++ b/aoc_2022/src/day_22.rs @@ -4,9 +4,9 @@ use std::collections::VecDeque; use common::{solution, Answer}; -type Point = nd_vec::Vec2; +solution!("Monkey Map", 22); -solution!("Monkey Map", (2022, 00)); +type Point = nd_vec::Vec2; fn part_a(input: &str) -> Answer { let mut world = World::parse(input); diff --git a/aoc_2022/src/day_23.rs b/aoc_2022/src/day_23.rs index 682d0d9..9140c6f 100644 --- a/aoc_2022/src/day_23.rs +++ b/aoc_2022/src/day_23.rs @@ -3,9 +3,9 @@ use hashbrown::{hash_map::Entry, HashMap, HashSet}; use common::{solution, Answer}; use nd_vec::vector; -type Point = nd_vec::Vec2; +solution!("Unstable Diffusion", 32); -solution!("Unstable Diffusion", (2022, 00)); +type Point = nd_vec::Vec2; fn part_a(input: &str) -> Answer { let mut world = World::parse(input); diff --git a/aoc_2022/src/day_24.rs b/aoc_2022/src/day_24.rs index dc8c122..f6ebaf0 100644 --- a/aoc_2022/src/day_24.rs +++ b/aoc_2022/src/day_24.rs @@ -3,9 +3,9 @@ use hashbrown::HashSet; use nd_vec::{vector, Vec2}; use pathfinding::directed::bfs::bfs; -type Pos = Vec2; +solution!("Blizzard Basin", 24); -solution!("Blizzard Basin", (2022, 00)); +type Pos = Vec2; fn part_a(input: &str) -> Answer { let basin = Basin::parse(input); diff --git a/aoc_2022/src/day_25.rs b/aoc_2022/src/day_25.rs index 447c45b..ed643be 100644 --- a/aoc_2022/src/day_25.rs +++ b/aoc_2022/src/day_25.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Full of Hot Air", (2022, 00)); +solution!("Full of Hot Air", 25); fn part_a(input: &str) -> Answer { snafu::encode(input.lines().map(snafu::decode).sum::()).into() diff --git a/aoc_2023/src/day_01.rs b/aoc_2023/src/day_01.rs index a3851a3..4b04763 100644 --- a/aoc_2023/src/day_01.rs +++ b/aoc_2023/src/day_01.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Trebuchet?!", (2023, 01)); +solution!("Trebuchet?!", 1); const DIGITS: [&str; 9] = [ "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", diff --git a/aoc_2023/src/day_02.rs b/aoc_2023/src/day_02.rs index 62def4c..dd6e812 100644 --- a/aoc_2023/src/day_02.rs +++ b/aoc_2023/src/day_02.rs @@ -1,16 +1,10 @@ -use common::{Answer, Solution}; +use common::{solution, Answer}; + +solution!("Cube Conundrum", 2); // 12 red cubes, 13 green cubes, and 14 blue cubes const MAX_CUBES: [u32; 3] = [12, 13, 14]; -pub const SOLUTION: Solution = Solution { - name: "Cube Conundrum", - date: (2023, 02), - - part_a, - part_b, -}; - fn part_a(input: &str) -> Answer { parse(input) .iter() diff --git a/aoc_2023/src/day_03.rs b/aoc_2023/src/day_03.rs index 2519de9..b7a6dce 100644 --- a/aoc_2023/src/day_03.rs +++ b/aoc_2023/src/day_03.rs @@ -6,7 +6,7 @@ use nd_vec::{vector, Vec2}; type Pos = Vec2; -solution!("Gear Ratios", (2023, 03)); +solution!("Gear Ratios", 3); fn part_a(input: &str) -> Answer { parse(input) diff --git a/aoc_2023/src/day_04.rs b/aoc_2023/src/day_04.rs index 120d862..6d5dcc4 100644 --- a/aoc_2023/src/day_04.rs +++ b/aoc_2023/src/day_04.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Scratchcards", (2023, 04)); +solution!("Scratchcards", 4); fn part_a(input: &str) -> Answer { let cards = parse(input); diff --git a/aoc_2023/src/day_05.rs b/aoc_2023/src/day_05.rs index 3f28e4b..3ec289c 100644 --- a/aoc_2023/src/day_05.rs +++ b/aoc_2023/src/day_05.rs @@ -1,7 +1,7 @@ use common::{solution, Answer}; use rayon::{iter::ParallelIterator, slice::ParallelSlice}; -solution!("If You Give A Seed A Fertilizer", (2023, 05)); +solution!("If You Give A Seed A Fertilizer", 5); fn part_a(input: &str) -> Answer { let seeds = parse(input); diff --git a/aoc_2023/src/day_06.rs b/aoc_2023/src/day_06.rs index 05d2326..dfc9eef 100644 --- a/aoc_2023/src/day_06.rs +++ b/aoc_2023/src/day_06.rs @@ -1,7 +1,7 @@ use common::{solution, Answer}; use itertools::Itertools; -solution!("Wait For It", (2023, 06)); +solution!("Wait For It", 6); fn part_a(input: &str) -> Answer { parse_a(input) diff --git a/aoc_2023/src/day_07.rs b/aoc_2023/src/day_07.rs index bb22605..ae72073 100644 --- a/aoc_2023/src/day_07.rs +++ b/aoc_2023/src/day_07.rs @@ -3,7 +3,7 @@ use std::{cmp::Ordering, fmt::Debug}; use common::{solution, Answer}; use itertools::Itertools; -solution!("Camel Cards", (2023, 04)); +solution!("Camel Cards", 7); fn part_a(input: &str) -> Answer { let hands = parse(input, "AKQJT98765432"); diff --git a/aoc_2023/src/day_08.rs b/aoc_2023/src/day_08.rs index fa464fb..350fc6a 100644 --- a/aoc_2023/src/day_08.rs +++ b/aoc_2023/src/day_08.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use common::{solution, Answer}; -solution!("Haunted Wasteland", (2023, 04)); +solution!("Haunted Wasteland", 8); /// Just start at `AAA` and follow the instructions until you reach `ZZZ`. fn part_a(input: &str) -> Answer { diff --git a/aoc_2023/src/day_09.rs b/aoc_2023/src/day_09.rs index a4b80e8..701ec8f 100644 --- a/aoc_2023/src/day_09.rs +++ b/aoc_2023/src/day_09.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Mirage Maintenance", (2023, 04)); +solution!("Mirage Maintenance", 9); fn part_a(input: &str) -> Answer { parse(input) diff --git a/aoc_2023/src/day_10.rs b/aoc_2023/src/day_10.rs index ff64ceb..c41c2f4 100644 --- a/aoc_2023/src/day_10.rs +++ b/aoc_2023/src/day_10.rs @@ -14,7 +14,7 @@ const START_PIECES: [(char, [Direction; 2]); 4] = [ ('L', [Direction::Up, Direction::Right]), ]; -solution!("Pipe Maze", (2023, 04)); +solution!("Pipe Maze", 10); fn part_a(input: &str) -> Answer { let maze = parse(input); diff --git a/aoc_2023/src/day_11.rs b/aoc_2023/src/day_11.rs index e28fcb6..3f3a1b5 100644 --- a/aoc_2023/src/day_11.rs +++ b/aoc_2023/src/day_11.rs @@ -6,7 +6,7 @@ use common::{solution, Answer}; type Pos = Vec2; -solution!("Cosmic Expansion", (2023, 04)); +solution!("Cosmic Expansion", 11); fn part_a(input: &str) -> Answer { let mut galaxies = parse(input); diff --git a/aoc_2023/src/day_12.rs b/aoc_2023/src/day_12.rs index eca1feb..f6af97d 100644 --- a/aoc_2023/src/day_12.rs +++ b/aoc_2023/src/day_12.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use common::{solution, Answer}; -solution!("Hot Springs", (2023, 04)); +solution!("Hot Springs", 12); fn part_a(input: &str) -> Answer { parse(input) diff --git a/aoc_2023/src/day_13.rs b/aoc_2023/src/day_13.rs index d6eb666..31da267 100644 --- a/aoc_2023/src/day_13.rs +++ b/aoc_2023/src/day_13.rs @@ -1,6 +1,6 @@ use common::{solution, Answer}; -solution!("Point of Incidence", (2023, 04)); +solution!("Point of Incidence", 13); fn part_a(input: &str) -> Answer { let valleys = parse(input); diff --git a/aoc_2023/src/day_14.rs b/aoc_2023/src/day_14.rs index 188944e..0936139 100644 --- a/aoc_2023/src/day_14.rs +++ b/aoc_2023/src/day_14.rs @@ -6,7 +6,7 @@ use nd_vec::{vector, Vec2}; type Pos = Vec2; -solution!("Parabolic Reflector Dish", (2023, 04)); +solution!("Parabolic Reflector Dish", 14); fn part_a(input: &str) -> Answer { let mut dish = parse(input); diff --git a/aoc_2023/src/day_15.rs b/aoc_2023/src/day_15.rs index 5e2aed8..6739ac8 100644 --- a/aoc_2023/src/day_15.rs +++ b/aoc_2023/src/day_15.rs @@ -1,7 +1,7 @@ use common::{solution, Answer}; use itertools::Itertools; -solution!("Lens Library", (2023, 04)); +solution!("Lens Library", 15); fn part_a(input: &str) -> Answer { input diff --git a/aoc_2023/src/day_16.rs b/aoc_2023/src/day_16.rs index e224258..87ff7f1 100644 --- a/aoc_2023/src/day_16.rs +++ b/aoc_2023/src/day_16.rs @@ -4,9 +4,9 @@ use aoc_lib::{direction::Direction, matrix::Matrix}; use common::{solution, Answer}; use nd_vec::{vector, Vec2}; -type Pos = Vec2; +solution!("The Floor Will Be Lava", 16); -solution!("The Floor Will Be Lava", (2023, 04)); +type Pos = Vec2; fn part_a(input: &str) -> Answer { lazer(&parse(input), vector!(-1, 0), Direction::Right).into() diff --git a/aoc_2023/src/day_17.rs b/aoc_2023/src/day_17.rs index e00cfa8..b527eb1 100644 --- a/aoc_2023/src/day_17.rs +++ b/aoc_2023/src/day_17.rs @@ -4,9 +4,9 @@ use aoc_lib::{direction::Direction, matrix::Matrix}; use common::{solution, Answer}; use nd_vec::{vector, Vec2}; -type Pos = Vec2; +solution!("Clumsy Crucible", 17); -solution!("Clumsy Crucible", (2023, 04)); +type Pos = Vec2; fn part_a(input: &str) -> Answer { pathfind(parse(input), 1, 3).into() diff --git a/aoc_2023/src/day_18.rs b/aoc_2023/src/day_18.rs index e43d65c..fdbf805 100644 --- a/aoc_2023/src/day_18.rs +++ b/aoc_2023/src/day_18.rs @@ -2,7 +2,7 @@ use aoc_lib::direction::Direction; use common::{solution, Answer}; use nd_vec::vector; -solution!("Lavaduct Lagoon", (2023, 04)); +solution!("Lavaduct Lagoon", 18); fn part_a(input: &str) -> Answer { solve(parse_a(input)).into() diff --git a/aoc_2023/src/day_19.rs b/aoc_2023/src/day_19.rs index c9e17d1..9029692 100644 --- a/aoc_2023/src/day_19.rs +++ b/aoc_2023/src/day_19.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use common::{solution, Answer}; -solution!("Aplenty", (2023, 04)); +solution!("Aplenty", 19); fn part_a(input: &str) -> Answer { let (rules, shapes) = parse(input); diff --git a/aoc_2023/src/day_20.rs b/aoc_2023/src/day_20.rs index d22e985..672363a 100644 --- a/aoc_2023/src/day_20.rs +++ b/aoc_2023/src/day_20.rs @@ -2,7 +2,7 @@ use std::collections::{HashMap, VecDeque}; use common::{solution, Answer}; -solution!("Pulse Propagation", (2023, 04)); +solution!("Pulse Propagation", 20); fn part_a(input: &str) -> Answer { let connections = parse_input(input); diff --git a/aoc_2023/src/day_21.rs b/aoc_2023/src/day_21.rs index 98880ff..d8765b2 100644 --- a/aoc_2023/src/day_21.rs +++ b/aoc_2023/src/day_21.rs @@ -6,7 +6,7 @@ use nd_vec::{vector, Vec2}; use polynomial::Polynomial; -solution!("Step Counter", (2023, 04)); +solution!("Step Counter", 21); fn part_a(input: &str) -> Answer { let map = parse(input); diff --git a/aoc_2023/src/day_22.rs b/aoc_2023/src/day_22.rs index 17ae63e..ace1e34 100644 --- a/aoc_2023/src/day_22.rs +++ b/aoc_2023/src/day_22.rs @@ -3,7 +3,7 @@ use std::{collections::HashSet, convert::identity}; use common::{solution, Answer}; use nd_vec::{vector, Vec3}; -solution!("Sand Slabs", (2023, 04)); +solution!("Sand Slabs", 22); fn part_a(input: &str) -> Answer { solve(parse(input), false, |x| (x == 0) as u32).into() diff --git a/aoc_2023/src/day_23.rs b/aoc_2023/src/day_23.rs index 731f5fd..6add1df 100644 --- a/aoc_2023/src/day_23.rs +++ b/aoc_2023/src/day_23.rs @@ -7,9 +7,9 @@ use aoc_lib::{direction::Direction, matrix::Matrix}; use common::{solution, Answer}; use nd_vec::{vector, Vec2}; -type Pos = Vec2; +solution!("A Long Walk", 23); -solution!("A Long Walk", (2023, 04)); +type Pos = Vec2; fn part_a(input: &str) -> Answer { solve_a(&parse(input), &mut HashSet::new(), vector!(1, 0), 0).into() diff --git a/aoc_2023/src/day_24.rs b/aoc_2023/src/day_24.rs index 6378d6a..e397219 100644 --- a/aoc_2023/src/day_24.rs +++ b/aoc_2023/src/day_24.rs @@ -5,7 +5,7 @@ use itertools::Itertools; use nd_vec::{vector, Vec2, Vec3}; use num_traits::Num; -solution!("Never Tell Me The Odds", (2023, 04)); +solution!("Never Tell Me The Odds", 24); fn part_a(input: &str) -> Answer { let stones = parse(input); diff --git a/aoc_2023/src/day_25.rs b/aoc_2023/src/day_25.rs index d962f7d..9de8108 100644 --- a/aoc_2023/src/day_25.rs +++ b/aoc_2023/src/day_25.rs @@ -4,7 +4,7 @@ use common::{solution, Answer}; use petgraph::{graph::UnGraph, stable_graph::NodeIndex, Graph, Undirected}; use rustworkx_core::connectivity::stoer_wagner_min_cut; -solution!("Snowverload", (2023, 04)); +solution!("Snowverload", 25); fn part_a(input: &str) -> Answer { let wires = parse(input); diff --git a/common/src/lib.rs b/common/src/lib.rs index c71513a..109a5cb 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -7,4 +7,4 @@ mod solution; pub use answer::Answer; pub use misc::{human_time, load}; pub use part::Part; -pub use solution::{DummySolution, ISolution, Solution}; +pub use solution::Solution; diff --git a/common/src/solution.rs b/common/src/solution.rs index 48a7db8..9d094ae 100644 --- a/common/src/solution.rs +++ b/common/src/solution.rs @@ -1,38 +1,8 @@ use crate::Answer; -pub trait ISolution { - fn name(&self) -> &'static str; - fn part_a(input: &str) -> Answer; - fn part_b(input: &str) -> Answer; - - fn is_dummy(&self) -> bool { - false - } -} - -pub struct DummySolution; - -impl ISolution for DummySolution { - fn name(&self) -> &'static str { - unreachable!() - } - - fn part_a(_input: &str) -> Answer { - unreachable!() - } - - fn part_b(_input: &str) -> Answer { - unreachable!() - } - - fn is_dummy(&self) -> bool { - true - } -} - pub struct Solution { pub name: &'static str, - pub date: (u16, u8), + pub day: u8, pub part_a: fn(&str) -> Answer, pub part_b: fn(&str) -> Answer, @@ -40,10 +10,10 @@ pub struct Solution { #[macro_export] macro_rules! solution { - ($name:expr, $date:expr) => { + ($name:expr, $day:expr) => { pub const SOLUTION: $crate::Solution = $crate::Solution { name: $name, - date: $date, + day: $day, part_a, part_b, diff --git a/src/commands/list.rs b/src/commands/list.rs index 1d667b5..9356b32 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -11,7 +11,7 @@ pub fn list(cmd: &ListArgs) -> Result<()> { println!( " {} Day {}: {}", if last { "└" } else { "├" }, - i + 1, + e.day, e.name ); } diff --git a/src/commands/run.rs b/src/commands/run.rs index 6966aa1..cca5f6c 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -9,7 +9,7 @@ pub fn run(cmd: &RunArgs) -> Result<()> { let solutions = get_year(cmd.year); let solution = solutions .iter() - .find(|x| x.date.1 == cmd.day) + .find(|x| x.day == cmd.day) .with_context(|| format!("No solution for day {} in year {}", cmd.day, cmd.year))?; println!(