use advent_of_code_traits::{days::*, run, SolutionRunner};
mod day01;
mod day02;
mod day03;
struct AdventOfCode2021<const DAY: u32>;
fn main() {
let day = std::env::args()
.skip(1)
.next()
.expect(
"need a day to know which solution to run, e.g. `cargo run --example cli 1` to run day 1 solutions",
)
.parse()
.expect("unable to parse day, just use a number like `1`");
let input = std::fs::read_to_string(&find_input(day)).expect("no input available for that day");
match day {
1 => run!(AdventOfCode2021::<Day1>, &input),
2 => run!(AdventOfCode2021::<Day2>, &input),
3 => run!(AdventOfCode2021::<Day3>, &input),
x => unimplemented!("no solution available for day {x}"),
}
}
fn find_input(day: u32) -> String {
let parent_dir = ["examples/cli/input/2021/", "cli/input/2021/", "input/2021/"]
.iter()
.filter(|path| std::path::Path::new(path).exists())
.next()
.expect("Please run this example from a folder in or above examples/cli");
format!("{}/day{:02}.txt", parent_dir, day)
}