From e2d219b331a878bbb3c9dcef9ea4e218b2e3ee06 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 11 Dec 2022 21:59:21 -0500 Subject: refactor --- src/opt.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/opt.rs (limited to 'src/opt.rs') diff --git a/src/opt.rs b/src/opt.rs new file mode 100644 index 0000000..296ea83 --- /dev/null +++ b/src/opt.rs @@ -0,0 +1,20 @@ +#[derive(Debug, structopt::StructOpt)] +#[structopt(about = "Advent of Code")] +pub struct Opt { + pub day: u8, + pub puzzle: u8, +} + +#[macro_export] +macro_rules! day { + ($year:expr, $day:expr, $puzzle:expr, $mod:ident) => {{ + let data = $mod::parse(parse::data($year, $day)?)?; + match $puzzle { + 1 => println!("{}", $mod::part1(data)?), + 2 => println!("{}", $mod::part2(data)?), + _ => { + panic!("unknown puzzle {} for day {}", $puzzle, $day) + } + } + }}; +} -- cgit v1.2.3-54-g00ecf