From 8fc2af19c876d7d5caba82fdd6cf209e6465a537 Mon Sep 17 00:00:00 2001 From: Jack Kinsey Date: Tue, 3 Dec 2024 22:40:45 -0500 Subject: [PATCH] Improve problem infra --- src/day00.rs | 27 +++++++++++++++++++++ src/main.rs | 68 ++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 src/day00.rs diff --git a/src/day00.rs b/src/day00.rs new file mode 100644 index 0000000..3cfb47c --- /dev/null +++ b/src/day00.rs @@ -0,0 +1,27 @@ +fn input() -> &'static str { + include_str!("../input/day00.txt") +} + +fn parse(input: &str) -> () { + todo!() +} + +pub fn part1() { + println!("Day 0 Part 1: {}", 0); +} + +pub fn part2() { + println!("Day 0 Part 2: {}", 0); +} + +#[cfg(test)] +mod test { + use super::*; + + const INPUT_STR: &str = concat!(); + + #[test] + fn test_parse() { + assert_eq!(parse(INPUT_STR), todo!()) + } +} diff --git a/src/main.rs b/src/main.rs index 5b055ca..48fa201 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,69 @@ pub mod day01; pub mod day02; +// pub mod day03; +// pub mod day04; +// pub mod day05; +// pub mod day06; +// pub mod day07; +// pub mod day08; +// pub mod day09; +// pub mod day10; +// pub mod day11; +// pub mod day12; +// pub mod day13; +// pub mod day14; +// pub mod day15; +// pub mod day16; +// pub mod day17; +// pub mod day18; +// pub mod day19; +// pub mod day20; +// pub mod day21; +// pub mod day22; +// pub mod day23; +// pub mod day24; +// pub mod day25; + +type Part = fn(); + +const DAYS: [(Part, Part); 2] = [ + (day01::part1 as fn(), day01::part2 as fn()), + (day02::part1 as fn(), day02::part2 as fn()), + // (day03::part1 as fn(), day03::part2 as fn()), + // (day04::part1 as fn(), day04::part2 as fn()), + // (day05::part1 as fn(), day05::part2 as fn()), + // (day06::part1 as fn(), day06::part2 as fn()), + // (day07::part1 as fn(), day07::part2 as fn()), + // (day08::part1 as fn(), day08::part2 as fn()), + // (day09::part1 as fn(), day09::part2 as fn()), + // (day10::part1 as fn(), day10::part2 as fn()), + // (day11::part1 as fn(), day11::part2 as fn()), + // (day12::part1 as fn(), day12::part2 as fn()), + // (day13::part1 as fn(), day13::part2 as fn()), + // (day14::part1 as fn(), day14::part2 as fn()), + // (day15::part1 as fn(), day15::part2 as fn()), + // (day16::part1 as fn(), day16::part2 as fn()), + // (day17::part1 as fn(), day17::part2 as fn()), + // (day18::part1 as fn(), day18::part2 as fn()), + // (day19::part1 as fn(), day19::part2 as fn()), + // (day20::part1 as fn(), day20::part2 as fn()), + // (day21::part1 as fn(), day21::part2 as fn()), + // (day22::part1 as fn(), day22::part2 as fn()), + // (day23::part1 as fn(), day23::part2 as fn()), + // (day24::part1 as fn(), day24::part2 as fn()), + // (day25::part1 as fn(), day25::part2 as fn()), +]; fn main() { - day01::part1(); - day01::part2(); - day02::part1(); - day02::part2(); + let args: Vec = std::env::args().collect(); + let day: usize = args + .get(1) + .expect("Please provide a day.") + .parse() + .expect("The day should be a number."); + if day < 1 || day > DAYS.len() { + panic!("That day hasn't been implemented yet!"); + } + DAYS[day - 1].0(); + DAYS[day - 1].1(); } -- 2.38.5