Skip to content

Commit df48bfe

Browse files
authored
feat: add macro arms for running individual parts of a solution (#44)
1 parent 9d06401 commit df48bfe

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/template/mod.rs

+22
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ pub fn read_file_part(folder: &str, day: Day, part: u8) -> String {
3434
}
3535

3636
/// Creates the constant `DAY` and sets up the input and runner for each part.
37+
///
38+
/// The optional, second parameter (1 or 2) allows you to only run a single part of the solution.
3739
#[macro_export]
3840
macro_rules! solution {
3941
($day:expr) => {
@@ -47,4 +49,24 @@ macro_rules! solution {
4749
run_part(part_two, &input, DAY, 2);
4850
}
4951
};
52+
($day:expr, 1) => {
53+
/// Allows solving part one in isolation
54+
const DAY: advent_of_code::template::Day = advent_of_code::day!($day);
55+
56+
fn main() {
57+
use advent_of_code::template::runner::*;
58+
let input = advent_of_code::template::read_file("inputs", DAY);
59+
run_part(part_one, &input, DAY, 1);
60+
}
61+
};
62+
($day:expr, 2) => {
63+
/// Allows solving part two in isolation
64+
const DAY: advent_of_code::template::Day = advent_of_code::day!($day);
65+
66+
fn main() {
67+
use advent_of_code::template::runner::*;
68+
let input = advent_of_code::template::read_file("inputs", DAY);
69+
run_part(part_two, &input, DAY, 2);
70+
}
71+
};
5072
}

0 commit comments

Comments
 (0)