1
0
Fork 0

solution: allow running sample as binary

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2022-12-11 13:42:17 +01:00
parent 1b3394fd94
commit 9ff562eef9
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -19,7 +19,7 @@ pub trait Solution<Input, Output: Display> {
fn part_1(input: &Input) -> Output;
fn part_2(input: &Input) -> Output;
fn main() -> Result<()>
fn run(type_of_input: &str) -> Result<()>
where
Self: Sized,
{
@ -33,13 +33,20 @@ pub trait Solution<Input, Output: Display> {
.init();
color_eyre::install()?;
let input = Self::parse_input(format!("inputs/{}.txt", Self::day()));
let input = Self::parse_input(format!("{}s/{}.txt", type_of_input, Self::day()));
info!("Part 1: {}", Self::part_1(&input));
info!("Part 2: {}", Self::part_2(&input));
Ok(())
}
fn main() -> Result<()>
where
Self: Sized,
{
Self::run("input")
}
}
#[macro_export]