55 lines
1.3 KiB
Rust
55 lines
1.3 KiB
Rust
pub mod day01;
|
|
pub mod day02;
|
|
pub mod day03;
|
|
pub mod day04;
|
|
pub mod day05;
|
|
pub mod day06;
|
|
pub mod day07;
|
|
pub mod day08;
|
|
pub mod day09;
|
|
pub mod day10;
|
|
pub mod day11;
|
|
pub mod day12;
|
|
pub mod day13;
|
|
pub mod day14;
|
|
pub mod day15;
|
|
pub mod day16;
|
|
pub mod day17;
|
|
pub mod day18;
|
|
pub mod day19;
|
|
pub mod day20;
|
|
pub mod day21;
|
|
pub mod day22;
|
|
pub mod day23;
|
|
pub mod day24;
|
|
pub mod day25;
|
|
|
|
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 + Sync>, Box<dyn Error>>;
|
|
fn part2(&self, input: &mut Vec<String>) -> Result<Box<dyn Display + Sync>, Box<dyn Error>>;
|
|
fn get_day(&self) -> u8;
|
|
|
|
fn run(&self) -> Result<Run, Box<dyn std::error::Error>> {
|
|
let start_time = SystemTime::now();
|
|
let run = Run {
|
|
part1: self.part1(get_input(self.get_day(), utils::InputType::Actual)?.as_mut())?,
|
|
part2: self.part2(get_input(self.get_day(), utils::InputType::Actual)?.as_mut())?,
|
|
day: self.get_day(),
|
|
time: SystemTime::now().duration_since(start_time)?,
|
|
};
|
|
Ok(run)
|
|
}
|
|
}
|
|
|
|
pub struct Run {
|
|
pub part1: Box<dyn Display + Sync>,
|
|
pub part2: Box<dyn Display + Sync>,
|
|
pub day: u8,
|
|
pub time: core::time::Duration,
|
|
}
|
|
|
|
unsafe impl Send for Run {}
|