summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
blob: 04bbb8543126eaf3c463bd702b307c6f137fbba0 (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
31
32
33
34
35
#![feature(iterator_try_collect)]
#![feature(iter_next_chunk)]
#![feature(associated_type_defaults)]

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

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

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

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

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

        Ok(())
    }
}

pub trait Problem {
    const DAY: u8;

    const INPUT: &'static str;
}

pub mod day_1;
pub mod day_2;
pub mod day_3;
pub mod day_4;
pub mod day_5;
pub mod day_6;
pub mod day_7;