diff --git a/aoc_2021/src/day_01.rs b/aoc_2021/src/day_01.rs index 9db5a86..32c8268 100644 --- a/aoc_2021/src/day_01.rs +++ b/aoc_2021/src/day_01.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day01; -impl Solution for Day01 { +impl ISolution for Day01 { fn name(&self) -> &'static str { "Sonar Sweep" } diff --git a/aoc_2021/src/day_02.rs b/aoc_2021/src/day_02.rs index e3e91a0..71daced 100644 --- a/aoc_2021/src/day_02.rs +++ b/aoc_2021/src/day_02.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day02; -impl Solution for Day02 { +impl ISolution for Day02 { fn name(&self) -> &'static str { "Dive!" } diff --git a/aoc_2021/src/day_03.rs b/aoc_2021/src/day_03.rs index 08bb4ea..911938d 100644 --- a/aoc_2021/src/day_03.rs +++ b/aoc_2021/src/day_03.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day03; -impl Solution for Day03 { +impl ISolution for Day03 { fn name(&self) -> &'static str { "Binary Diagnostic" } diff --git a/aoc_2021/src/day_04.rs b/aoc_2021/src/day_04.rs index 6e8ab07..59a3f08 100644 --- a/aoc_2021/src/day_04.rs +++ b/aoc_2021/src/day_04.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day04; -impl Solution for Day04 { +impl ISolution for Day04 { fn name(&self) -> &'static str { "Giant Squid" } diff --git a/aoc_2021/src/day_05.rs b/aoc_2021/src/day_05.rs index a4cf340..28a0010 100644 --- a/aoc_2021/src/day_05.rs +++ b/aoc_2021/src/day_05.rs @@ -1,10 +1,10 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use hashbrown::HashMap; pub struct Day05; -impl Solution for Day05 { +impl ISolution for Day05 { fn name(&self) -> &'static str { "Hydrothermal Venture" } diff --git a/aoc_2021/src/day_06.rs b/aoc_2021/src/day_06.rs index 583d9a9..b79d576 100644 --- a/aoc_2021/src/day_06.rs +++ b/aoc_2021/src/day_06.rs @@ -1,4 +1,4 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use std::hash::Hash; @@ -6,7 +6,7 @@ use hashbrown::HashMap; pub struct Day06; -impl Solution for Day06 { +impl ISolution for Day06 { fn name(&self) -> &'static str { "Lanternfish" } diff --git a/aoc_2021/src/day_07.rs b/aoc_2021/src/day_07.rs index e6a345c..6d5d05d 100644 --- a/aoc_2021/src/day_07.rs +++ b/aoc_2021/src/day_07.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day07; -impl Solution for Day07 { +impl ISolution for Day07 { fn name(&self) -> &'static str { "The Treachery of Whales" } diff --git a/aoc_2021/src/day_08.rs b/aoc_2021/src/day_08.rs index e746fef..3cd6d76 100644 --- a/aoc_2021/src/day_08.rs +++ b/aoc_2021/src/day_08.rs @@ -1,4 +1,4 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use hashbrown::HashMap; @@ -10,7 +10,7 @@ const DIGITS: [&str; 10] = [ pub struct Day08; -impl Solution for Day08 { +impl ISolution for Day08 { fn name(&self) -> &'static str { "Seven Segment Search" } diff --git a/aoc_2021/src/day_09.rs b/aoc_2021/src/day_09.rs index 992c789..8301469 100644 --- a/aoc_2021/src/day_09.rs +++ b/aoc_2021/src/day_09.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day09; -impl Solution for Day09 { +impl ISolution for Day09 { fn name(&self) -> &'static str { "Smoke Basin" } diff --git a/aoc_2021/src/day_10.rs b/aoc_2021/src/day_10.rs index 0cb1b88..7b74942 100644 --- a/aoc_2021/src/day_10.rs +++ b/aoc_2021/src/day_10.rs @@ -1,10 +1,10 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; const CHARS: [(char, char); 4] = [('(', ')'), ('[', ']'), ('{', '}'), ('<', '>')]; pub struct Day10; -impl Solution for Day10 { +impl ISolution for Day10 { fn name(&self) -> &'static str { "Syntax Scoring" } diff --git a/aoc_2021/src/day_11.rs b/aoc_2021/src/day_11.rs index 83e8c1a..3d51894 100644 --- a/aoc_2021/src/day_11.rs +++ b/aoc_2021/src/day_11.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day11; -impl Solution for Day11 { +impl ISolution for Day11 { fn name(&self) -> &'static str { "Dumbo Octopus" } diff --git a/aoc_2021/src/day_12.rs b/aoc_2021/src/day_12.rs index 10ad1f9..a7c8277 100644 --- a/aoc_2021/src/day_12.rs +++ b/aoc_2021/src/day_12.rs @@ -1,10 +1,10 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use hashbrown::{HashMap, HashSet}; use petgraph::graph::{NodeIndex, UnGraph}; pub struct Day12; -impl Solution for Day12 { +impl ISolution for Day12 { fn name(&self) -> &'static str { "Passage Pathing" } @@ -103,7 +103,7 @@ fn parse(input: &str) -> ParseResult { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day12; diff --git a/aoc_2021/src/day_13.rs b/aoc_2021/src/day_13.rs index 4580f81..ca24764 100644 --- a/aoc_2021/src/day_13.rs +++ b/aoc_2021/src/day_13.rs @@ -1,13 +1,13 @@ use hashbrown::HashSet; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::vector; type Point = nd_vec::Vec2; pub struct Day13; -impl Solution for Day13 { +impl ISolution for Day13 { fn name(&self) -> &'static str { "Transparent Origami" } diff --git a/aoc_2021/src/day_14.rs b/aoc_2021/src/day_14.rs index 224ef7c..1b5acd3 100644 --- a/aoc_2021/src/day_14.rs +++ b/aoc_2021/src/day_14.rs @@ -1,10 +1,10 @@ use hashbrown::HashMap; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day14; -impl Solution for Day14 { +impl ISolution for Day14 { fn name(&self) -> &'static str { "Extended Polymerization" } diff --git a/aoc_2021/src/day_15.rs b/aoc_2021/src/day_15.rs index e660a69..b7382b8 100644 --- a/aoc_2021/src/day_15.rs +++ b/aoc_2021/src/day_15.rs @@ -1,11 +1,11 @@ use aoc_lib::{direction::Direction, matrix::Matrix}; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use hashbrown::HashMap; use nd_vec::vector; pub struct Day15; -impl Solution for Day15 { +impl ISolution for Day15 { fn name(&self) -> &'static str { "Chiton" } @@ -51,7 +51,7 @@ impl Solution for Day15 { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day15; diff --git a/aoc_2021/src/lib.rs b/aoc_2021/src/lib.rs index f3b6a68..4914480 100644 --- a/aoc_2021/src/lib.rs +++ b/aoc_2021/src/lib.rs @@ -1,4 +1,4 @@ -pub use common::Solution; +pub use common::ISolution; mod day_01; mod day_02; @@ -17,7 +17,7 @@ mod day_14; mod day_15; // [import_marker] -pub const ALL: &[&dyn Solution] = &[ +pub const ALL: &[&dyn ISolution] = &[ &day_01::Day01, &day_02::Day02, &day_03::Day03, diff --git a/aoc_2022/src/day_01.rs b/aoc_2022/src/day_01.rs index cfbfab5..8e8d13e 100644 --- a/aoc_2022/src/day_01.rs +++ b/aoc_2022/src/day_01.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day01; -impl Solution for Day01 { +impl ISolution for Day01 { fn name(&self) -> &'static str { "Calorie Counting" } diff --git a/aoc_2022/src/day_02.rs b/aoc_2022/src/day_02.rs index da8e07b..6c8e314 100644 --- a/aoc_2022/src/day_02.rs +++ b/aoc_2022/src/day_02.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day02; -impl Solution for Day02 { +impl ISolution for Day02 { fn name(&self) -> &'static str { "Rock Paper Scissors" } diff --git a/aoc_2022/src/day_03.rs b/aoc_2022/src/day_03.rs index 61bd12e..dbee174 100644 --- a/aoc_2022/src/day_03.rs +++ b/aoc_2022/src/day_03.rs @@ -1,10 +1,10 @@ use hashbrown::HashSet; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day03; -impl Solution for Day03 { +impl ISolution for Day03 { fn name(&self) -> &'static str { "Rucksack Reorganization" } diff --git a/aoc_2022/src/day_04.rs b/aoc_2022/src/day_04.rs index 492b1de..df201a5 100644 --- a/aoc_2022/src/day_04.rs +++ b/aoc_2022/src/day_04.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day04; -impl Solution for Day04 { +impl ISolution for Day04 { fn name(&self) -> &'static str { "Camp Cleanup" } diff --git a/aoc_2022/src/day_05.rs b/aoc_2022/src/day_05.rs index 9dc88ac..2cb3821 100644 --- a/aoc_2022/src/day_05.rs +++ b/aoc_2022/src/day_05.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day05; -impl Solution for Day05 { +impl ISolution for Day05 { fn name(&self) -> &'static str { "Supply Stacks" } diff --git a/aoc_2022/src/day_06.rs b/aoc_2022/src/day_06.rs index 12a978e..cd6e413 100644 --- a/aoc_2022/src/day_06.rs +++ b/aoc_2022/src/day_06.rs @@ -1,10 +1,10 @@ use hashbrown::HashSet; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day06; -impl Solution for Day06 { +impl ISolution for Day06 { fn name(&self) -> &'static str { "Tuning Trouble" } diff --git a/aoc_2022/src/day_07.rs b/aoc_2022/src/day_07.rs index 3268519..4504179 100644 --- a/aoc_2022/src/day_07.rs +++ b/aoc_2022/src/day_07.rs @@ -1,10 +1,10 @@ use hashbrown::HashSet; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day07; -impl Solution for Day07 { +impl ISolution for Day07 { fn name(&self) -> &'static str { "No Space Left On Device" } diff --git a/aoc_2022/src/day_08.rs b/aoc_2022/src/day_08.rs index a9a1b4b..900ad50 100644 --- a/aoc_2022/src/day_08.rs +++ b/aoc_2022/src/day_08.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day08; -impl Solution for Day08 { +impl ISolution for Day08 { fn name(&self) -> &'static str { "Treetop Tree House" } diff --git a/aoc_2022/src/day_09.rs b/aoc_2022/src/day_09.rs index b8b536a..25c7c26 100644 --- a/aoc_2022/src/day_09.rs +++ b/aoc_2022/src/day_09.rs @@ -2,14 +2,14 @@ use std::vec; use hashbrown::HashSet; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::vector; type Point = nd_vec::Vec2; pub struct Day09; -impl Solution for Day09 { +impl ISolution for Day09 { fn name(&self) -> &'static str { "Rope Bridge" } diff --git a/aoc_2022/src/day_10.rs b/aoc_2022/src/day_10.rs index 4816f93..857b022 100644 --- a/aoc_2022/src/day_10.rs +++ b/aoc_2022/src/day_10.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day10; -impl Solution for Day10 { +impl ISolution for Day10 { fn name(&self) -> &'static str { "Cathode-Ray Tube" } diff --git a/aoc_2022/src/day_11.rs b/aoc_2022/src/day_11.rs index 9ceeae5..3377d36 100644 --- a/aoc_2022/src/day_11.rs +++ b/aoc_2022/src/day_11.rs @@ -1,10 +1,10 @@ use std::collections::VecDeque; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day11; -impl Solution for Day11 { +impl ISolution for Day11 { fn name(&self) -> &'static str { "Monkey in the Middle" } diff --git a/aoc_2022/src/day_12.rs b/aoc_2022/src/day_12.rs index bf8d23f..dd5a87f 100644 --- a/aoc_2022/src/day_12.rs +++ b/aoc_2022/src/day_12.rs @@ -1,13 +1,13 @@ use std::collections::VecDeque; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::vector; type Point = nd_vec::Vec2; pub struct Day12; -impl Solution for Day12 { +impl ISolution for Day12 { fn name(&self) -> &'static str { "Hill Climbing Algorithm" } diff --git a/aoc_2022/src/day_13.rs b/aoc_2022/src/day_13.rs index 9ceb4ac..f0becc2 100644 --- a/aoc_2022/src/day_13.rs +++ b/aoc_2022/src/day_13.rs @@ -1,10 +1,10 @@ use std::cmp::Ordering; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day13; -impl Solution for Day13 { +impl ISolution for Day13 { fn name(&self) -> &'static str { "Distress Signal" } diff --git a/aoc_2022/src/day_14.rs b/aoc_2022/src/day_14.rs index 0303638..b48cb89 100644 --- a/aoc_2022/src/day_14.rs +++ b/aoc_2022/src/day_14.rs @@ -1,4 +1,4 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::vector; type Point = nd_vec::Vec2; @@ -7,7 +7,7 @@ const NEW_POINT: Point = vector!(500, 0); pub struct Day14; -impl Solution for Day14 { +impl ISolution for Day14 { fn name(&self) -> &'static str { "Regolith Reservoir" } diff --git a/aoc_2022/src/day_15.rs b/aoc_2022/src/day_15.rs index 336fe81..ce2c0f9 100644 --- a/aoc_2022/src/day_15.rs +++ b/aoc_2022/src/day_15.rs @@ -1,4 +1,4 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::vector; use rayon::prelude::*; @@ -7,7 +7,7 @@ type Point = nd_vec::Vec2; pub struct Day15; -impl Solution for Day15 { +impl ISolution for Day15 { fn name(&self) -> &'static str { "Beacon Exclusion Zone" } diff --git a/aoc_2022/src/day_16.rs b/aoc_2022/src/day_16.rs index 91a2f95..ec5d1b9 100644 --- a/aoc_2022/src/day_16.rs +++ b/aoc_2022/src/day_16.rs @@ -1,12 +1,12 @@ use std::collections::VecDeque; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use hashbrown::HashMap; pub struct Day16; -impl Solution for Day16 { +impl ISolution for Day16 { fn name(&self) -> &'static str { "Proboscidea Volcanium" } @@ -158,7 +158,7 @@ fn parse(input: &str) -> ParseResult { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day16; diff --git a/aoc_2022/src/day_17.rs b/aoc_2022/src/day_17.rs index 899bbe1..6889f67 100644 --- a/aoc_2022/src/day_17.rs +++ b/aoc_2022/src/day_17.rs @@ -1,13 +1,13 @@ use hashbrown::{hash_map::Entry, HashMap}; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::vector; type Point = nd_vec::Vec2; pub struct Day17; -impl Solution for Day17 { +impl ISolution for Day17 { fn name(&self) -> &'static str { "Pyroclastic Flow" } diff --git a/aoc_2022/src/day_18.rs b/aoc_2022/src/day_18.rs index 3602f62..97a5cf0 100644 --- a/aoc_2022/src/day_18.rs +++ b/aoc_2022/src/day_18.rs @@ -1,13 +1,13 @@ use hashbrown::HashSet; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::{vector, Vector}; type Pos = nd_vec::Vec3; pub struct Day18; -impl Solution for Day18 { +impl ISolution for Day18 { fn name(&self) -> &'static str { "Boiling Boulders" } diff --git a/aoc_2022/src/day_19.rs b/aoc_2022/src/day_19.rs index 226300e..83666ea 100644 --- a/aoc_2022/src/day_19.rs +++ b/aoc_2022/src/day_19.rs @@ -1,9 +1,9 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use hashbrown::HashMap; pub struct Day19; -impl Solution for Day19 { +impl ISolution for Day19 { fn name(&self) -> &'static str { "Not Enough Minerals " } @@ -198,7 +198,7 @@ mod test { use indoc::indoc; use super::Day19; - use common::Solution; + use common::ISolution; const CASE: &str = indoc! {" Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 2 ore. Each obsidian robot costs 3 ore and 14 clay. Each geode robot costs 2 ore and 7 obsidian. diff --git a/aoc_2022/src/day_20.rs b/aoc_2022/src/day_20.rs index 1e68664..49edae1 100644 --- a/aoc_2022/src/day_20.rs +++ b/aoc_2022/src/day_20.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day20; -impl Solution for Day20 { +impl ISolution for Day20 { fn name(&self) -> &'static str { "Grove Positioning System" } diff --git a/aoc_2022/src/day_21.rs b/aoc_2022/src/day_21.rs index db49d82..ba4b5be 100644 --- a/aoc_2022/src/day_21.rs +++ b/aoc_2022/src/day_21.rs @@ -1,10 +1,10 @@ use hashbrown::HashMap; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day21; -impl Solution for Day21 { +impl ISolution for Day21 { fn name(&self) -> &'static str { "Monkey Math" } diff --git a/aoc_2022/src/day_22.rs b/aoc_2022/src/day_22.rs index 9c83474..44c1488 100644 --- a/aoc_2022/src/day_22.rs +++ b/aoc_2022/src/day_22.rs @@ -2,12 +2,12 @@ use hashbrown::HashSet; use nd_vec::vector; use std::collections::VecDeque; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; type Point = nd_vec::Vec2; pub struct Day22; -impl Solution for Day22 { +impl ISolution for Day22 { fn name(&self) -> &'static str { "Monkey Map" } @@ -217,7 +217,7 @@ fn wrap_3d(world: &World, mut _pos: Point) -> Option<(Point, Direction)> { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day22; diff --git a/aoc_2022/src/day_23.rs b/aoc_2022/src/day_23.rs index b830e6a..5801ab4 100644 --- a/aoc_2022/src/day_23.rs +++ b/aoc_2022/src/day_23.rs @@ -1,13 +1,13 @@ use hashbrown::{hash_map::Entry, HashMap, HashSet}; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::vector; type Point = nd_vec::Vec2; pub struct Day23; -impl Solution for Day23 { +impl ISolution for Day23 { fn name(&self) -> &'static str { "Unstable Diffusion" } @@ -151,7 +151,7 @@ impl World { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::{Day23, World}; diff --git a/aoc_2022/src/day_24.rs b/aoc_2022/src/day_24.rs index ff220af..04cdac1 100644 --- a/aoc_2022/src/day_24.rs +++ b/aoc_2022/src/day_24.rs @@ -1,4 +1,4 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use hashbrown::HashSet; use nd_vec::{vector, Vec2}; use pathfinding::directed::bfs::bfs; @@ -7,7 +7,7 @@ type Pos = Vec2; pub struct Day24; -impl Solution for Day24 { +impl ISolution for Day24 { fn name(&self) -> &'static str { "Blizzard Basin" } @@ -237,7 +237,7 @@ impl Tile { mod test { use indoc::indoc; - use common::Solution; + use common::ISolution; use super::{Basin, Day24}; diff --git a/aoc_2022/src/day_25.rs b/aoc_2022/src/day_25.rs index 6b36cc4..06b2e2e 100644 --- a/aoc_2022/src/day_25.rs +++ b/aoc_2022/src/day_25.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day25; -impl Solution for Day25 { +impl ISolution for Day25 { fn name(&self) -> &'static str { "Full of Hot Air" } @@ -53,7 +53,7 @@ mod test { use indoc::indoc; use super::Day25; - use common::Solution; + use common::ISolution; const CASE: &str = indoc! {r" 1=-0-2 diff --git a/aoc_2022/src/lib.rs b/aoc_2022/src/lib.rs index 9716c9e..2ac6514 100644 --- a/aoc_2022/src/lib.rs +++ b/aoc_2022/src/lib.rs @@ -1,4 +1,4 @@ -use common::Solution; +use common::ISolution; mod day_01; mod day_02; @@ -26,7 +26,7 @@ mod day_23; mod day_24; mod day_25; -pub const ALL: [&dyn Solution; 25] = [ +pub const ALL: [&dyn ISolution; 25] = [ &day_01::Day01, &day_02::Day02, &day_03::Day03, diff --git a/aoc_2023/src/day_01.rs b/aoc_2023/src/day_01.rs index c643f4d..c2ee306 100644 --- a/aoc_2023/src/day_01.rs +++ b/aoc_2023/src/day_01.rs @@ -1,37 +1,37 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution, Solution}; -pub struct Day01; +pub const SOLUTION: Solution = Solution { + name: "Trebuchet?!", + date: (2023, 01), + + part_a, + part_b, +}; const DIGITS: [&str; 9] = [ "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", ]; -impl Solution for Day01 { - fn name(&self) -> &'static str { - "Trebuchet?!" +fn part_a(input: &str) -> Answer { + let mut sum = 0; + for line in input.lines() { + let mut digits = line.chars().filter_map(|c| c.to_digit(10)); + let first = digits.next().unwrap(); + let last = digits.last().unwrap_or(first); + sum += first * 10 + last; } - fn part_a(&self, input: &str) -> Answer { - let mut sum = 0; - for line in input.lines() { - let mut digits = line.chars().filter_map(|c| c.to_digit(10)); - let first = digits.next().unwrap(); - let last = digits.last().unwrap_or(first); - sum += first * 10 + last; - } + sum.into() +} - sum.into() +fn part_b(input: &str) -> Answer { + let mut sum = 0; + for line in input.lines() { + let digits = digits(line); + sum += digits[0] * 10 + digits[1]; } - fn part_b(&self, input: &str) -> Answer { - let mut sum = 0; - for line in input.lines() { - let digits = digits(line); - sum += digits[0] * 10 + digits[1]; - } - - sum.into() - } + sum.into() } fn digits(i: &str) -> [u32; 2] { @@ -61,11 +61,9 @@ fn digits(i: &str) -> [u32; 2] { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; - use super::Day01; - const CASE_A: &str = indoc! {" 1abc2 pqr3stu8vwx @@ -85,11 +83,11 @@ mod test { #[test] fn part_a() { - assert_eq!(Day01.part_a(CASE_A), 142.into()); + assert_eq!(super::part_a(CASE_A), 142.into()); } #[test] fn part_b() { - assert_eq!(Day01.part_b(CASE_B), 281.into()); + assert_eq!(super::part_b(CASE_B), 281.into()); } } diff --git a/aoc_2023/src/day_02.rs b/aoc_2023/src/day_02.rs index 00075f5..9e2309c 100644 --- a/aoc_2023/src/day_02.rs +++ b/aoc_2023/src/day_02.rs @@ -1,38 +1,40 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution, Solution}; pub struct Day02; // 12 red cubes, 13 green cubes, and 14 blue cubes const MAX_CUBES: [u32; 3] = [12, 13, 14]; -impl Solution for Day02 { - fn name(&self) -> &'static str { - "Cube Conundrum" - } - - fn part_a(&self, input: &str) -> Answer { - parse(input) - .iter() - .enumerate() - .filter(|(_, games)| games.iter().all(|game| game.is_possible())) - .map(|x| x.0 + 1) - .sum::() - .into() - } +pub const SOLUTION: Solution = Solution { + name: "Cube Conundrum", + date: (2023, 02), + + part_a, + part_b, +}; + +fn part_a(input: &str) -> Answer { + parse(input) + .iter() + .enumerate() + .filter(|(_, games)| games.iter().all(|game| game.is_possible())) + .map(|x| x.0 + 1) + .sum::() + .into() +} - fn part_b(&self, input: &str) -> Answer { - parse(input) - .iter() - .map(|games| { - let mut max = CubeSet::default(); - for game in games { - max = max.max(game); - } - max.red * max.green * max.blue - }) - .sum::() - .into() - } +fn part_b(input: &str) -> Answer { + parse(input) + .iter() + .map(|games| { + let mut max = CubeSet::default(); + for game in games { + max = max.max(game); + } + max.red * max.green * max.blue + }) + .sum::() + .into() } fn parse(input: &str) -> Vec> { @@ -87,11 +89,9 @@ impl CubeSet { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; - use super::Day02; - const CASE: &str = indoc! {" Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue @@ -102,11 +102,11 @@ mod test { #[test] fn part_a() { - assert_eq!(Day02.part_a(CASE), 8.into()); + assert_eq!(super::part_a(CASE), 8.into()); } #[test] fn part_b() { - assert_eq!(Day02.part_b(CASE), 2286.into()); + assert_eq!(super::part_b(CASE), 2286.into()); } } diff --git a/aoc_2023/src/day_03.rs b/aoc_2023/src/day_03.rs index 5ace191..b2f79dc 100644 --- a/aoc_2023/src/day_03.rs +++ b/aoc_2023/src/day_03.rs @@ -1,37 +1,37 @@ use std::collections::HashMap; use aoc_lib::regex; -use common::{Answer, Solution}; +use common::{Answer, ISolution, Solution}; use nd_vec::{vector, Vec2}; type Pos = Vec2; -pub struct Day03; - -impl Solution for Day03 { - fn name(&self) -> &'static str { - "Gear Ratios" - } - - fn part_a(&self, input: &str) -> Answer { - parse(input) - .gears - .iter() - .filter(|x| x.part_number) - .map(|x| x.value) - .sum::() - .into() - } +pub const SOLUTION: Solution = Solution { + name: "Gear Ratios", + date: (2023, 03), + + part_a, + part_b, +}; + +fn part_a(input: &str) -> Answer { + parse(input) + .gears + .iter() + .filter(|x| x.part_number) + .map(|x| x.value) + .sum::() + .into() +} - fn part_b(&self, input: &str) -> Answer { - parse(input) - .ratios - .iter() - .filter(|(_, vals)| vals.len() == 2) - .map(|(_, vals)| vals[0] * vals[1]) - .sum::() - .into() - } +fn part_b(input: &str) -> Answer { + parse(input) + .ratios + .iter() + .filter(|(_, vals)| vals.len() == 2) + .map(|(_, vals)| vals[0] * vals[1]) + .sum::() + .into() } struct ParseResult { @@ -83,11 +83,9 @@ struct Gear { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; - use super::Day03; - const CASE: &str = indoc! {" 467..114.. ...*...... @@ -103,11 +101,11 @@ mod test { #[test] fn part_a() { - assert_eq!(Day03.part_a(CASE), 4361.into()); + assert_eq!(super::part_a(CASE), 4361.into()); } #[test] fn part_b() { - assert_eq!(Day03.part_b(CASE), 467835.into()); + assert_eq!(super::part_b(CASE), 467835.into()); } } diff --git a/aoc_2023/src/day_04.rs b/aoc_2023/src/day_04.rs index c92b2b7..d9d39d5 100644 --- a/aoc_2023/src/day_04.rs +++ b/aoc_2023/src/day_04.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day04; -impl Solution for Day04 { +impl ISolution for Day04 { fn name(&self) -> &'static str { "Scratchcards" } @@ -67,7 +67,7 @@ fn parse(input: &str) -> Vec { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day04; diff --git a/aoc_2023/src/day_05.rs b/aoc_2023/src/day_05.rs index 3858f63..bcc021f 100644 --- a/aoc_2023/src/day_05.rs +++ b/aoc_2023/src/day_05.rs @@ -1,9 +1,9 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use rayon::{iter::ParallelIterator, slice::ParallelSlice}; pub struct Day05; -impl Solution for Day05 { +impl ISolution for Day05 { fn name(&self) -> &'static str { "If You Give A Seed A Fertilizer" } @@ -117,7 +117,7 @@ impl Map { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day05; diff --git a/aoc_2023/src/day_06.rs b/aoc_2023/src/day_06.rs index 9fec616..0c77de2 100644 --- a/aoc_2023/src/day_06.rs +++ b/aoc_2023/src/day_06.rs @@ -1,9 +1,9 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use itertools::Itertools; pub struct Day06; -impl Solution for Day06 { +impl ISolution for Day06 { fn name(&self) -> &'static str { "Wait For It" } @@ -69,7 +69,7 @@ impl Race { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day06; diff --git a/aoc_2023/src/day_07.rs b/aoc_2023/src/day_07.rs index f5244d5..924ccca 100644 --- a/aoc_2023/src/day_07.rs +++ b/aoc_2023/src/day_07.rs @@ -1,11 +1,11 @@ use std::{cmp::Ordering, fmt::Debug}; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use itertools::Itertools; pub struct Day07; -impl Solution for Day07 { +impl ISolution for Day07 { fn name(&self) -> &'static str { "Camel Cards" } @@ -140,7 +140,7 @@ impl Hand { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day07; diff --git a/aoc_2023/src/day_08.rs b/aoc_2023/src/day_08.rs index b86d68a..c23e9cf 100644 --- a/aoc_2023/src/day_08.rs +++ b/aoc_2023/src/day_08.rs @@ -1,10 +1,10 @@ use std::collections::HashMap; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day08; -impl Solution for Day08 { +impl ISolution for Day08 { fn name(&self) -> &'static str { "Haunted Wasteland" } @@ -101,7 +101,7 @@ fn parse(input: &str) -> Map { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day08; diff --git a/aoc_2023/src/day_09.rs b/aoc_2023/src/day_09.rs index ee39a73..27a609c 100644 --- a/aoc_2023/src/day_09.rs +++ b/aoc_2023/src/day_09.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day09; -impl Solution for Day09 { +impl ISolution for Day09 { fn name(&self) -> &'static str { "Mirage Maintenance" } @@ -72,7 +72,7 @@ impl Sequence { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day09; diff --git a/aoc_2023/src/day_10.rs b/aoc_2023/src/day_10.rs index 17c104a..b1a8a18 100644 --- a/aoc_2023/src/day_10.rs +++ b/aoc_2023/src/day_10.rs @@ -3,7 +3,7 @@ use std::collections::HashSet; use nd_vec::{vector, Vec2}; use aoc_lib::direction::Direction; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; type Pos = Vec2; @@ -16,7 +16,7 @@ const START_PIECES: [(char, [Direction; 2]); 4] = [ pub struct Day10; -impl Solution for Day10 { +impl ISolution for Day10 { fn name(&self) -> &'static str { "Pipe Maze" } @@ -178,7 +178,7 @@ fn turn(facing: Direction, tile: char) -> TurnResult { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day10; diff --git a/aoc_2023/src/day_11.rs b/aoc_2023/src/day_11.rs index 6496c4f..f1ed61f 100644 --- a/aoc_2023/src/day_11.rs +++ b/aoc_2023/src/day_11.rs @@ -2,13 +2,13 @@ use bitvec::{bitvec, vec::BitVec}; use itertools::Itertools; use nd_vec::{vector, Vec2}; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; type Pos = Vec2; pub struct Day11; -impl Solution for Day11 { +impl ISolution for Day11 { fn name(&self) -> &'static str { "Cosmic Expansion" } @@ -85,7 +85,7 @@ impl Galaxies { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day11; diff --git a/aoc_2023/src/day_12.rs b/aoc_2023/src/day_12.rs index c8e2435..f254c18 100644 --- a/aoc_2023/src/day_12.rs +++ b/aoc_2023/src/day_12.rs @@ -1,10 +1,10 @@ use std::collections::HashMap; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day12; -impl Solution for Day12 { +impl ISolution for Day12 { fn name(&self) -> &'static str { "Hot Springs" } @@ -102,7 +102,7 @@ impl Spring { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day12; diff --git a/aoc_2023/src/day_13.rs b/aoc_2023/src/day_13.rs index 4e7edb1..a9bcdc0 100644 --- a/aoc_2023/src/day_13.rs +++ b/aoc_2023/src/day_13.rs @@ -1,8 +1,8 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day13; -impl Solution for Day13 { +impl ISolution for Day13 { fn name(&self) -> &'static str { "Point of Incidence" } @@ -93,7 +93,7 @@ impl Valley { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day13; diff --git a/aoc_2023/src/day_14.rs b/aoc_2023/src/day_14.rs index 21cba6e..b0b123d 100644 --- a/aoc_2023/src/day_14.rs +++ b/aoc_2023/src/day_14.rs @@ -1,14 +1,14 @@ use std::{collections::HashMap, convert::identity, hash::Hash}; use aoc_lib::matrix::Matrix; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::{vector, Vec2}; type Pos = Vec2; pub struct Day14; -impl Solution for Day14 { +impl ISolution for Day14 { fn name(&self) -> &'static str { "Parabolic Reflector Dish" } @@ -104,7 +104,7 @@ impl Dish { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day14; diff --git a/aoc_2023/src/day_15.rs b/aoc_2023/src/day_15.rs index 70dc3e0..4310f67 100644 --- a/aoc_2023/src/day_15.rs +++ b/aoc_2023/src/day_15.rs @@ -1,9 +1,9 @@ -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use itertools::Itertools; pub struct Day15; -impl Solution for Day15 { +impl ISolution for Day15 { fn name(&self) -> &'static str { "Lens Library" } @@ -70,7 +70,7 @@ fn hash(input: &str) -> u8 { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day15; diff --git a/aoc_2023/src/day_16.rs b/aoc_2023/src/day_16.rs index bd63c45..7caf37b 100644 --- a/aoc_2023/src/day_16.rs +++ b/aoc_2023/src/day_16.rs @@ -1,14 +1,14 @@ use std::collections::HashSet; use aoc_lib::{direction::Direction, matrix::Matrix}; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::{vector, Vec2}; type Pos = Vec2; pub struct Day16; -impl Solution for Day16 { +impl ISolution for Day16 { fn name(&self) -> &'static str { "The Floor Will Be Lava" } @@ -124,7 +124,7 @@ impl Tile { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day16; diff --git a/aoc_2023/src/day_17.rs b/aoc_2023/src/day_17.rs index a43b1a8..46d59f4 100644 --- a/aoc_2023/src/day_17.rs +++ b/aoc_2023/src/day_17.rs @@ -1,14 +1,14 @@ use std::collections::{HashMap, VecDeque}; use aoc_lib::{direction::Direction, matrix::Matrix}; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::{vector, Vec2}; type Pos = Vec2; pub struct Day17; -impl Solution for Day17 { +impl ISolution for Day17 { fn name(&self) -> &'static str { "Clumsy Crucible" } @@ -91,7 +91,7 @@ impl State { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day17; diff --git a/aoc_2023/src/day_18.rs b/aoc_2023/src/day_18.rs index 26441d7..8450388 100644 --- a/aoc_2023/src/day_18.rs +++ b/aoc_2023/src/day_18.rs @@ -1,10 +1,10 @@ use aoc_lib::direction::Direction; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::vector; pub struct Day18; -impl Solution for Day18 { +impl ISolution for Day18 { fn name(&self) -> &'static str { "Lavaduct Lagoon" } @@ -84,7 +84,7 @@ fn parse_a(input: &str) -> Vec<(Direction, u32)> { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day18; diff --git a/aoc_2023/src/day_19.rs b/aoc_2023/src/day_19.rs index d852783..b260af8 100644 --- a/aoc_2023/src/day_19.rs +++ b/aoc_2023/src/day_19.rs @@ -1,10 +1,10 @@ use std::collections::HashMap; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day19; -impl Solution for Day19 { +impl ISolution for Day19 { fn name(&self) -> &'static str { "Aplenty" } @@ -189,7 +189,7 @@ fn field_idx(field: &str) -> usize { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day19; diff --git a/aoc_2023/src/day_20.rs b/aoc_2023/src/day_20.rs index 09be525..480ea73 100644 --- a/aoc_2023/src/day_20.rs +++ b/aoc_2023/src/day_20.rs @@ -1,10 +1,10 @@ use std::collections::{HashMap, VecDeque}; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; pub struct Day20; -impl Solution for Day20 { +impl ISolution for Day20 { fn name(&self) -> &'static str { "Pulse Propagation" } @@ -195,7 +195,7 @@ fn parse_input(input: &str) -> HashMap<&str, Connection<'_>> { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day20; diff --git a/aoc_2023/src/day_21.rs b/aoc_2023/src/day_21.rs index 33aaa73..796bf97 100644 --- a/aoc_2023/src/day_21.rs +++ b/aoc_2023/src/day_21.rs @@ -1,14 +1,14 @@ use std::collections::HashSet; use aoc_lib::{direction::Direction, matrix::Matrix}; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::{vector, Vec2}; use polynomial::Polynomial; pub struct Day21; -impl Solution for Day21 { +impl ISolution for Day21 { fn name(&self) -> &'static str { "Step Counter" } @@ -103,7 +103,7 @@ fn parse(input: &str) -> Matrix { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day21; diff --git a/aoc_2023/src/day_22.rs b/aoc_2023/src/day_22.rs index 23bd8ac..98505c9 100644 --- a/aoc_2023/src/day_22.rs +++ b/aoc_2023/src/day_22.rs @@ -1,11 +1,11 @@ use std::{collections::HashSet, convert::identity}; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::{vector, Vec3}; pub struct Day22; -impl Solution for Day22 { +impl ISolution for Day22 { fn name(&self) -> &'static str { "Sand Slabs" } @@ -107,7 +107,7 @@ fn parse(input: &str) -> Vec { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day22; diff --git a/aoc_2023/src/day_23.rs b/aoc_2023/src/day_23.rs index dd88c1c..dec1f11 100644 --- a/aoc_2023/src/day_23.rs +++ b/aoc_2023/src/day_23.rs @@ -4,14 +4,14 @@ use std::{ }; use aoc_lib::{direction::Direction, matrix::Matrix}; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use nd_vec::{vector, Vec2}; type Pos = Vec2; pub struct Day23; -impl Solution for Day23 { +impl ISolution for Day23 { fn name(&self) -> &'static str { "A Long Walk" } @@ -145,7 +145,7 @@ fn dir_matches(dir: Direction, chr: char) -> bool { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day23; diff --git a/aoc_2023/src/day_24.rs b/aoc_2023/src/day_24.rs index 9570187..014aa33 100644 --- a/aoc_2023/src/day_24.rs +++ b/aoc_2023/src/day_24.rs @@ -1,13 +1,13 @@ use std::{fmt::Display, ops::RangeInclusive}; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use itertools::Itertools; use nd_vec::{vector, Vec2, Vec3}; use num_traits::Num; pub struct Day24; -impl Solution for Day24 { +impl ISolution for Day24 { fn name(&self) -> &'static str { "Never Tell Me The Odds" } diff --git a/aoc_2023/src/day_25.rs b/aoc_2023/src/day_25.rs index b8e17d6..78d1be9 100644 --- a/aoc_2023/src/day_25.rs +++ b/aoc_2023/src/day_25.rs @@ -1,12 +1,12 @@ use std::collections::HashMap; -use common::{Answer, Solution}; +use common::{Answer, ISolution}; use petgraph::{graph::UnGraph, stable_graph::NodeIndex, Graph, Undirected}; use rustworkx_core::connectivity::stoer_wagner_min_cut; pub struct Day25; -impl Solution for Day25 { +impl ISolution for Day25 { fn name(&self) -> &'static str { "Snowverload" } @@ -60,7 +60,7 @@ fn parse(input: &str) -> Wires { #[cfg(test)] mod test { - use common::Solution; + use common::ISolution; use indoc::indoc; use super::Day25; diff --git a/aoc_2023/src/lib.rs b/aoc_2023/src/lib.rs index a800719..95cf531 100644 --- a/aoc_2023/src/lib.rs +++ b/aoc_2023/src/lib.rs @@ -1,4 +1,4 @@ -use common::Solution; +use common::ISolution; mod day_01; mod day_02; @@ -28,10 +28,7 @@ mod day_25; // [import_marker] #[rustfmt::skip] -pub const ALL: &[&dyn Solution] = &[ - &day_01::Day01, - &day_02::Day02, - &day_03::Day03, +pub const ALL: &[&dyn ISolution] = &[ &day_04::Day04, &day_05::Day05, &day_06::Day06, diff --git a/common/src/lib.rs b/common/src/lib.rs index 345dfcf..b1a944e 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -6,4 +6,4 @@ mod solution; pub use answer::Answer; pub use misc::{human_time, load}; pub use part::Part; -pub use solution::{DummySolution, Solution}; +pub use solution::{DummySolution, ISolution, Solution}; diff --git a/common/src/solution.rs b/common/src/solution.rs index b84d6b4..cc1e78e 100644 --- a/common/src/solution.rs +++ b/common/src/solution.rs @@ -1,6 +1,6 @@ use crate::Answer; -pub trait Solution { +pub trait ISolution { fn name(&self) -> &'static str; fn part_a(&self, input: &str) -> Answer; fn part_b(&self, input: &str) -> Answer; @@ -12,7 +12,7 @@ pub trait Solution { pub struct DummySolution; -impl Solution for DummySolution { +impl ISolution for DummySolution { fn name(&self) -> &'static str { unreachable!() } @@ -29,3 +29,11 @@ impl Solution for DummySolution { true } } + +pub struct Solution { + pub name: &'static str, + pub date: (u16, u8), + + pub part_a: fn(&str) -> Answer, + pub part_b: fn(&str) -> Answer, +} diff --git a/src/main.rs b/src/main.rs index 2eb6e01..ad4a971 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use anyhow::Result; use clap::Parser; use args::{Args, Commands}; -use common::Solution; +use common::ISolution; mod args; mod commands; @@ -17,7 +17,7 @@ fn main() -> Result<()> { Ok(()) } -fn get_year(year: u16) -> &'static [&'static dyn Solution] { +fn get_year(year: u16) -> &'static [&'static dyn ISolution] { match year { 2021 => aoc_2021::ALL, 2022 => &aoc_2022::ALL,