generated from AdventOfCode/AdventOfCodeXXXX
Initial commit
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
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};
|
||||
|
||||
// Solution class running your answers for part 1 and 2.
|
||||
pub trait Solution: Send + Sync {
|
||||
// Insert your solution for part one in here,
|
||||
// returning it as a:
|
||||
///```
|
||||
/// OK(Box::new(ans))
|
||||
/// ```
|
||||
fn part1(&self, input: &mut Vec<String>) -> Result<Box<dyn Display>, Box<dyn Error>>;
|
||||
|
||||
// Insert your solution for part two in here,
|
||||
// returning it as a:
|
||||
///```
|
||||
/// OK(Box::new(ans))
|
||||
/// ```
|
||||
fn part2(&self, input: &mut Vec<String>) -> Result<Box<dyn Display>, Box<dyn Error>>;
|
||||
|
||||
// Returns the day that is currently being run
|
||||
fn get_day(&self) -> u8;
|
||||
|
||||
// Runs part 1 and 2 for each day synchronously (One after the other)
|
||||
fn run(&self) -> Result<Run, Box<dyn std::error::Error>> {
|
||||
let start_time = SystemTime::now();
|
||||
|
||||
self.part1(get_input(self.get_day(), utils::InputType::Test1)?.as_mut())?;
|
||||
self.part2(get_input(self.get_day(), utils::InputType::Test2)?.as_mut())?;
|
||||
|
||||
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>,
|
||||
pub part2: Box<dyn Display>,
|
||||
pub day: u8,
|
||||
pub time: core::time::Duration,
|
||||
}
|
||||
|
||||
unsafe impl Send for Run {}
|
||||
Reference in New Issue
Block a user