From fb4ac26f324fbd4f40dbd06fda2c5dcdf84946d8 Mon Sep 17 00:00:00 2001 From: Matt Clarke Date: Tue, 5 Dec 2023 13:31:31 +0000 Subject: [PATCH 1/2] Add macro arm for only running single part of days solution --- src/template/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/template/mod.rs b/src/template/mod.rs index d1533e1..f8d019c 100644 --- a/src/template/mod.rs +++ b/src/template/mod.rs @@ -45,4 +45,22 @@ macro_rules! solution { run_part(part_two, &input, DAY, 2); } }; + ($day:expr, 1) => { /// Allows solving part one in isolation + const DAY: advent_of_code::Day = advent_of_code::day!($day); + + fn main() { + use advent_of_code::template::runner::*; + let input = advent_of_code::template::read_file("inputs", DAY); + run_part(part_one, &input, DAY, 1); + } + }; + ($day:expr, 2) => { /// Allows solving part two in isolation + const DAY: advent_of_code::Day = advent_of_code::day!($day); + + fn main() { + use advent_of_code::template::runner::*; + let input = advent_of_code::template::read_file("inputs", DAY); + run_part(part_two, &input, DAY, 2); + } + }; } From b91e7e0af1cc9186c270fd89e17dbe43468f7949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sp=C3=B6ttel?= <1682504+fspoettel@users.noreply.github.com> Date: Tue, 5 Dec 2023 22:54:32 +0100 Subject: [PATCH 2/2] chore: run `fmt`, update docstring --- src/template/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/template/mod.rs b/src/template/mod.rs index c7822f5..49402b2 100644 --- a/src/template/mod.rs +++ b/src/template/mod.rs @@ -34,6 +34,8 @@ pub fn read_file_part(folder: &str, day: Day, part: u8) -> String { } /// Creates the constant `DAY` and sets up the input and runner for each part. +/// +/// The optional, second parameter (1 or 2) allows you to only run a single part of the solution. #[macro_export] macro_rules! solution { ($day:expr) => { @@ -47,7 +49,8 @@ macro_rules! solution { run_part(part_two, &input, DAY, 2); } }; - ($day:expr, 1) => { /// Allows solving part one in isolation + ($day:expr, 1) => { + /// Allows solving part one in isolation const DAY: advent_of_code::template::Day = advent_of_code::day!($day); fn main() { @@ -56,7 +59,8 @@ macro_rules! solution { run_part(part_one, &input, DAY, 1); } }; - ($day:expr, 2) => { /// Allows solving part two in isolation + ($day:expr, 2) => { + /// Allows solving part two in isolation const DAY: advent_of_code::template::Day = advent_of_code::day!($day); fn main() {