summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
blob: f077524aa36c44a76c84506e45b021ec5836250a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#![feature(iterator_try_collect)]
 
pub mod day_01;
pub mod day_02;

pub trait Problem {
    const DAY: u8;

    const INPUT: &'static str;
}

pub trait Solution: Problem {
    type Answer1: std::fmt::Display + Default;

    type Answer2: std::fmt::Display + Default;

    fn part_1(input: &str) -> anyhow::Result<Self::Answer1>;

    fn part_2(input: &str) -> anyhow::Result<Self::Answer2>;

    fn solve() -> anyhow::Result<()> {
        println!("Day {}.1", Self::DAY);
        println!("{}\n", Self::part_1(Self::INPUT)?);

        println!("Day {}.2", Self::DAY);
        println!("{}\n", Self::part_2(Self::INPUT)?);

        Ok(())
    }
}