blob: 47562cb8812d35037d0562c5abaad0e8d2454267 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#![feature(
iterator_try_collect,
iter_array_chunks,
array_windows,
iter_intersperse,
impl_trait_in_assoc_type
)]
pub mod day_01;
pub mod day_02;
pub mod day_03;
pub mod day_04;
pub mod day_05;
pub mod day_06;
pub mod day_07;
pub mod day_08;
pub mod day_09;
pub mod day_10;
pub mod day_11;
pub mod day_12;
pub mod day_13;
pub mod day_14;
pub mod day_15;
pub mod day_16;
pub mod day_17;
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<()> {
print!("Day {}.1", Self::DAY);
let timer = std::time::SystemTime::now();
let answer = Self::part_1(Self::INPUT)?;
let duration = timer.elapsed()?;
println!(" ({:.2}ms)", duration.as_micros() as f64 / 100f64);
println!("{answer}\n");
print!("Day {}.2", Self::DAY);
let timer = std::time::SystemTime::now();
let answer = Self::part_2(Self::INPUT)?;
let duration = timer.elapsed()?;
println!(" ({:.2}ms)", duration.as_micros() as f64 / 100f64);
println!("{answer}\n");
Ok(())
}
}
|