40 lines
1.3 KiB
Rust
40 lines
1.3 KiB
Rust
pub mod day01;
|
|
pub mod day02;
|
|
pub mod day03;
|
|
|
|
use crate::utils::{self, get_input};
|
|
use std::{error::Error, fmt::Display, time::SystemTime};
|
|
|
|
pub trait Solution {
|
|
fn part1(&self, input: &mut Vec<String>) -> Result<Box<dyn Display>, Box<dyn Error>>;
|
|
fn part2(&self, input: &mut Vec<String>) -> Result<Box<dyn Display>, Box<dyn Error>>;
|
|
fn get_day(&self) -> u8;
|
|
|
|
fn run(&self) -> Result<(), Box<dyn std::error::Error>> {
|
|
println!("========== Day {} ==========", self.get_day());
|
|
let start_time = SystemTime::now();
|
|
println!(
|
|
"Part1 Test: {}",
|
|
self.part1(get_input(self.get_day(), utils::InputType::Test1)?.as_mut())?
|
|
);
|
|
println!(
|
|
"Part1 Result: {}",
|
|
self.part1(get_input(self.get_day(), utils::InputType::Actual)?.as_mut())?
|
|
);
|
|
|
|
println!(
|
|
"Part2 Test: {}",
|
|
self.part2(get_input(self.get_day(), utils::InputType::Test2)?.as_mut())?
|
|
);
|
|
println!(
|
|
"Part2 Result: {}",
|
|
self.part2(get_input(self.get_day(), utils::InputType::Actual)?.as_mut())?
|
|
);
|
|
println!(
|
|
"========= {}ms =========",
|
|
SystemTime::now().duration_since(start_time)?.as_millis()
|
|
);
|
|
Ok(())
|
|
}
|
|
}
|