From 6646e1d9d06ef6231990fac0262bf1e5c80e1e27 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 22 Nov 2024 10:59:40 +0000 Subject: [PATCH] Completed template for advent of code XXXX --- create.py | 13 ------------- src/solutions/mod.rs | 15 +++++++++++++++ src/utils.rs | 2 ++ 3 files changed, 17 insertions(+), 13 deletions(-) delete mode 100644 create.py diff --git a/create.py b/create.py deleted file mode 100644 index 49ac506..0000000 --- a/create.py +++ /dev/null @@ -1,13 +0,0 @@ - - -for day in range(1, 26): - boilerplate = open(".\\src\\solutions\\dayxx.rs", "r").read() - boilerplate = boilerplate.replace("0", str(day)) - boilerplate = boilerplate.replace("XX", f"{day:02d}") - - new_code = open(f".\\src\\solutions\\day{day:02d}.rs", "w") - new_code.write(boilerplate) - - f = open(f".\\input\\day{day:02d}", "x") - f = open(f".\\input\\day{day:02d}_test1", "x") - f = open(f".\\input\\day{day:02d}_test2", "x") \ No newline at end of file diff --git a/src/solutions/mod.rs b/src/solutions/mod.rs index 7b9f7a2..368f621 100644 --- a/src/solutions/mod.rs +++ b/src/solutions/mod.rs @@ -27,11 +27,26 @@ 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) -> Result, Box>; + + // Insert your solution for part two in here, + // returning it as a: + ///``` + /// OK(Box::new(ans)) + /// ``` fn part2(&self, input: &mut Vec) -> Result, Box>; + + // 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> { let start_time = SystemTime::now(); diff --git a/src/utils.rs b/src/utils.rs index 6b75d79..10a4dec 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -33,3 +33,5 @@ pub fn get_input(day: u8, input: InputType) -> Result, Box