Advent of Code solutions
1use crate::parser::{Selection, DP};
2
3use super::MAX_DAY;
4
5pub trait Year {
6 const YEAR: usize;
7
8 fn solve_day(day: usize, part: usize, input: Option<&str>) -> Option<String>;
9
10 fn bench_day(day: usize, part: usize, input: Option<&str>);
11
12 fn solve_day_both_parts(day: usize, extra_indent: &str);
13
14 fn solve_all_days() {
15 println!("Year {}:", Self::YEAR);
16 for day in 1..=MAX_DAY {
17 Self::solve_day_both_parts(day, " ");
18 }
19 }
20
21 fn run_dp(input: Option<&str>, dp: DP) {
22 match dp.day {
23 Selection::All => {
24 Self::solve_all_days();
25 }
26 Selection::Single(day) => match dp.part {
27 Selection::All => {
28 Self::solve_day_both_parts(day, "");
29 }
30 Selection::Single(part) => {
31 Self::solve_day(day, part, input);
32 }
33 },
34 }
35 }
36
37 fn bench_dp(input: Option<&str>, dp: DP) {
38 match dp.day {
39 Selection::Single(day) => match dp.part {
40 Selection::Single(part) => {
41 Self::bench_day(day, part, input);
42 }
43 _ => panic!("Cannot bench all parts, sorry :("),
44 },
45 _ => panic!("Cannot bench all days, sorry :("),
46 }
47 }
48}