commit 470f4ab60c0c008980d051ef195ee715b30eeaa3 Author: Luke Else Date: Mon Dec 1 09:03:07 2025 +0000 Initial commit diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..d7cf579 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,25 @@ +{ + "name": "AOC", + "image": "git.luke-else.co.uk/luke-else/rust-dev:latest", + "remoteUser": "dev", + "customizations": { + "vscode": { + "settings": { + "editor.formatOnSave": true, + "[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer" + }, + "rust-analyzer.cargo.runBuildScripts": true + }, + "extensions": [ + "ms-azuretools.vscode-docker", + "rust-lang.rust-analyzer", + "tamasfe.even-better-toml", + "vadimcn.vscode-lldb", + "dustypomerleau.rust-syntax" + ] + } + }, + "postCreateCommand": "cargo fetch" +} + diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml new file mode 100644 index 0000000..48d4266 --- /dev/null +++ b/.gitea/workflows/test.yaml @@ -0,0 +1,56 @@ +on: [push, pull_request] + +name: Continuous integration + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + cache: false + - run: cargo check + + test: + name: Test Suite + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + cache: false + - run: cargo test + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + cache: false + - run: rustup component add rustfmt + - run: cargo fmt --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + cache: false + - run: rustup component add clippy + - run: cargo clippy -- -D warnings + + build: + name: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + cache: false + - run: cargo build \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..24801c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +# ---> VisualStudioCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# ---> Rust +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..44d1799 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "advent_of_code_XXXX" +version = "0.1.0" +edition = "2021" + +[dependencies] +tokio = {version = "1.41.1", features = ["full"]} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4af7a91 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2024 luke-else + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1d41d5d --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# AdventOfCodeXXXX + +Advent of Code XXXX Written in Rust. \ No newline at end of file diff --git a/assets/images/main.png b/assets/images/main.png new file mode 100644 index 0000000..88eebf8 Binary files /dev/null and b/assets/images/main.png differ diff --git a/input/day01 b/input/day01 new file mode 100644 index 0000000..e69de29 diff --git a/input/day01_test1 b/input/day01_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day01_test2 b/input/day01_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day02 b/input/day02 new file mode 100644 index 0000000..e69de29 diff --git a/input/day02_test1 b/input/day02_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day02_test2 b/input/day02_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day03 b/input/day03 new file mode 100644 index 0000000..e69de29 diff --git a/input/day03_test1 b/input/day03_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day03_test2 b/input/day03_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day04 b/input/day04 new file mode 100644 index 0000000..e69de29 diff --git a/input/day04_test1 b/input/day04_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day04_test2 b/input/day04_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day05 b/input/day05 new file mode 100644 index 0000000..e69de29 diff --git a/input/day05_test1 b/input/day05_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day05_test2 b/input/day05_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day06 b/input/day06 new file mode 100644 index 0000000..e69de29 diff --git a/input/day06_test1 b/input/day06_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day06_test2 b/input/day06_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day07 b/input/day07 new file mode 100644 index 0000000..e69de29 diff --git a/input/day07_test1 b/input/day07_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day07_test2 b/input/day07_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day08 b/input/day08 new file mode 100644 index 0000000..e69de29 diff --git a/input/day08_test1 b/input/day08_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day08_test2 b/input/day08_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day09 b/input/day09 new file mode 100644 index 0000000..e69de29 diff --git a/input/day09_test1 b/input/day09_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day09_test2 b/input/day09_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day10 b/input/day10 new file mode 100644 index 0000000..e69de29 diff --git a/input/day10_test1 b/input/day10_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day10_test2 b/input/day10_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day11 b/input/day11 new file mode 100644 index 0000000..e69de29 diff --git a/input/day11_test1 b/input/day11_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day11_test2 b/input/day11_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day12 b/input/day12 new file mode 100644 index 0000000..e69de29 diff --git a/input/day12_test1 b/input/day12_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day12_test2 b/input/day12_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day13 b/input/day13 new file mode 100644 index 0000000..e69de29 diff --git a/input/day13_test1 b/input/day13_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day13_test2 b/input/day13_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day14 b/input/day14 new file mode 100644 index 0000000..e69de29 diff --git a/input/day14_test1 b/input/day14_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day14_test2 b/input/day14_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day15 b/input/day15 new file mode 100644 index 0000000..e69de29 diff --git a/input/day15_test1 b/input/day15_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day15_test2 b/input/day15_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day16 b/input/day16 new file mode 100644 index 0000000..e69de29 diff --git a/input/day16_test1 b/input/day16_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day16_test2 b/input/day16_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day17 b/input/day17 new file mode 100644 index 0000000..e69de29 diff --git a/input/day17_test1 b/input/day17_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day17_test2 b/input/day17_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day18 b/input/day18 new file mode 100644 index 0000000..e69de29 diff --git a/input/day18_test1 b/input/day18_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day18_test2 b/input/day18_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day19 b/input/day19 new file mode 100644 index 0000000..e69de29 diff --git a/input/day19_test1 b/input/day19_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day19_test2 b/input/day19_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day20 b/input/day20 new file mode 100644 index 0000000..e69de29 diff --git a/input/day20_test1 b/input/day20_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day20_test2 b/input/day20_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day21 b/input/day21 new file mode 100644 index 0000000..e69de29 diff --git a/input/day21_test1 b/input/day21_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day21_test2 b/input/day21_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day22 b/input/day22 new file mode 100644 index 0000000..e69de29 diff --git a/input/day22_test1 b/input/day22_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day22_test2 b/input/day22_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day23 b/input/day23 new file mode 100644 index 0000000..e69de29 diff --git a/input/day23_test1 b/input/day23_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day23_test2 b/input/day23_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day24 b/input/day24 new file mode 100644 index 0000000..e69de29 diff --git a/input/day24_test1 b/input/day24_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day24_test2 b/input/day24_test2 new file mode 100644 index 0000000..e69de29 diff --git a/input/day25 b/input/day25 new file mode 100644 index 0000000..e69de29 diff --git a/input/day25_test1 b/input/day25_test1 new file mode 100644 index 0000000..e69de29 diff --git a/input/day25_test2 b/input/day25_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..f19220b --- /dev/null +++ b/src/main.rs @@ -0,0 +1,68 @@ +mod solutions; +mod utils; + +use std::{error::Error, time::SystemTime}; + +use solutions::*; + +#[tokio::main] +async fn main() -> Result<(), Box> { + /* Uncomment these before the start of each day! */ + let days: Vec> = vec![ + Box::new(day01::Day01 {}), + // Box::new(day02::Day02 {}), + // Box::new(day03::Day03 {}), + // Box::new(day04::Day04 {}), + // Box::new(day05::Day05 {}), + // Box::new(day06::Day06 {}), + // Box::new(day07::Day07 {}), + // Box::new(day08::Day08 {}), + // Box::new(day09::Day09 {}), + // Box::new(day10::Day10 {}), + // Box::new(day11::Day11 {}), + // Box::new(day12::Day12 {}), + // Box::new(day13::Day13 {}), + // Box::new(day14::Day14 {}), + // Box::new(day15::Day15 {}), + // Box::new(day16::Day16 {}), + // Box::new(day17::Day17 {}), + // Box::new(day18::Day18 {}), + // Box::new(day19::Day19 {}), + // Box::new(day20::Day20 {}), + // Box::new(day21::Day21 {}), + // Box::new(day22::Day22 {}), + // Box::new(day23::Day23 {}), + // Box::new(day24::Day24 {}), + // Box::new(day25::Day25 {}), + ]; + + // Vector to store every solution as a thread handle + let mut t = vec![]; + + // Run through and construct solution objects + for day in days { + let task = tokio::spawn(async move { day.run().unwrap() }); + t.push(task); + } + + let start_time = SystemTime::now(); + + // When thread is awaited, the solution is run + let mut days = vec![]; + for thread in t { + days.push(thread.await?); + } + + for day in days { + println!("========= Day {} ==========", day.day); + println!("Part1 Result: {}", day.part1); + println!("Part2 Result: {}", day.part2); + println!("========= {}ms =========\n", day.time.as_millis()); + } + + println!( + "Ran AoC 2023 in {}ms", + SystemTime::now().duration_since(start_time)?.as_millis() + ); + Ok(()) +} diff --git a/src/solutions/day01.rs b/src/solutions/day01.rs new file mode 100644 index 0000000..9c6edbc --- /dev/null +++ b/src/solutions/day01.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day01 {} + +impl Solution for Day01 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 1 + } +} + +impl Day01 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day01::Day01 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day01::Day01 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day02.rs b/src/solutions/day02.rs new file mode 100644 index 0000000..3ca9181 --- /dev/null +++ b/src/solutions/day02.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day02 {} + +impl Solution for Day02 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 2 + } +} + +impl Day02 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day02::Day02 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day02::Day02 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day03.rs b/src/solutions/day03.rs new file mode 100644 index 0000000..eade51a --- /dev/null +++ b/src/solutions/day03.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day03 {} + +impl Solution for Day03 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 3 + } +} + +impl Day03 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day03::Day03 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day03::Day03 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day04.rs b/src/solutions/day04.rs new file mode 100644 index 0000000..9c3adcc --- /dev/null +++ b/src/solutions/day04.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day04 {} + +impl Solution for Day04 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 4 + } +} + +impl Day04 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day04::Day04 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day04::Day04 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day05.rs b/src/solutions/day05.rs new file mode 100644 index 0000000..5371019 --- /dev/null +++ b/src/solutions/day05.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day05 {} + +impl Solution for Day05 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 5 + } +} + +impl Day05 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day05::Day05 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day05::Day05 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day06.rs b/src/solutions/day06.rs new file mode 100644 index 0000000..a874f45 --- /dev/null +++ b/src/solutions/day06.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day06 {} + +impl Solution for Day06 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 6 + } +} + +impl Day06 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day06::Day06 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day06::Day06 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day07.rs b/src/solutions/day07.rs new file mode 100644 index 0000000..b73a00d --- /dev/null +++ b/src/solutions/day07.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day07 {} + +impl Solution for Day07 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 7 + } +} + +impl Day07 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day07::Day07 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day07::Day07 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day08.rs b/src/solutions/day08.rs new file mode 100644 index 0000000..d6c2668 --- /dev/null +++ b/src/solutions/day08.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day08 {} + +impl Solution for Day08 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 8 + } +} + +impl Day08 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day08::Day08 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day08::Day08 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day09.rs b/src/solutions/day09.rs new file mode 100644 index 0000000..3ce348a --- /dev/null +++ b/src/solutions/day09.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day09 {} + +impl Solution for Day09 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 9 + } +} + +impl Day09 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day09::Day09 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day09::Day09 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day10.rs b/src/solutions/day10.rs new file mode 100644 index 0000000..3ab58ef --- /dev/null +++ b/src/solutions/day10.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day10 {} + +impl Solution for Day10 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 10 + } +} + +impl Day10 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day10::Day10 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day10::Day10 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day11.rs b/src/solutions/day11.rs new file mode 100644 index 0000000..b019d00 --- /dev/null +++ b/src/solutions/day11.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day11 {} + +impl Solution for Day11 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 11 + } +} + +impl Day11 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day11::Day11 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day11::Day11 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day12.rs b/src/solutions/day12.rs new file mode 100644 index 0000000..f1ea006 --- /dev/null +++ b/src/solutions/day12.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day12 {} + +impl Solution for Day12 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 12 + } +} + +impl Day12 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day12::Day12 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day12::Day12 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day13.rs b/src/solutions/day13.rs new file mode 100644 index 0000000..20a3ae8 --- /dev/null +++ b/src/solutions/day13.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day13 {} + +impl Solution for Day13 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 13 + } +} + +impl Day13 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day13::Day13 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day13::Day13 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day14.rs b/src/solutions/day14.rs new file mode 100644 index 0000000..eee2290 --- /dev/null +++ b/src/solutions/day14.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day14 {} + +impl Solution for Day14 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 14 + } +} + +impl Day14 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day14::Day14 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day14::Day14 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day15.rs b/src/solutions/day15.rs new file mode 100644 index 0000000..38322e2 --- /dev/null +++ b/src/solutions/day15.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day15 {} + +impl Solution for Day15 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 15 + } +} + +impl Day15 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day15::Day15 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day15::Day15 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day16.rs b/src/solutions/day16.rs new file mode 100644 index 0000000..9c1fe90 --- /dev/null +++ b/src/solutions/day16.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day16 {} + +impl Solution for Day16 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 16 + } +} + +impl Day16 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day16::Day16 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day16::Day16 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day17.rs b/src/solutions/day17.rs new file mode 100644 index 0000000..2f7dba5 --- /dev/null +++ b/src/solutions/day17.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day17 {} + +impl Solution for Day17 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 17 + } +} + +impl Day17 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day17::Day17 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day17::Day17 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day18.rs b/src/solutions/day18.rs new file mode 100644 index 0000000..4db1e9c --- /dev/null +++ b/src/solutions/day18.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day18 {} + +impl Solution for Day18 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 18 + } +} + +impl Day18 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day18::Day18 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day18::Day18 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day19.rs b/src/solutions/day19.rs new file mode 100644 index 0000000..babf9c7 --- /dev/null +++ b/src/solutions/day19.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day19 {} + +impl Solution for Day19 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 19 + } +} + +impl Day19 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day19::Day19 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day19::Day19 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day20.rs b/src/solutions/day20.rs new file mode 100644 index 0000000..e4f3d4a --- /dev/null +++ b/src/solutions/day20.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day20 {} + +impl Solution for Day20 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 20 + } +} + +impl Day20 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day20::Day20 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day20::Day20 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day21.rs b/src/solutions/day21.rs new file mode 100644 index 0000000..f4ce049 --- /dev/null +++ b/src/solutions/day21.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day21 {} + +impl Solution for Day21 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 21 + } +} + +impl Day21 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day21::Day21 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day21::Day21 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day22.rs b/src/solutions/day22.rs new file mode 100644 index 0000000..a336b17 --- /dev/null +++ b/src/solutions/day22.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day22 {} + +impl Solution for Day22 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 22 + } +} + +impl Day22 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day22::Day22 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day22::Day22 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day23.rs b/src/solutions/day23.rs new file mode 100644 index 0000000..6b12cef --- /dev/null +++ b/src/solutions/day23.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day23 {} + +impl Solution for Day23 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 23 + } +} + +impl Day23 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day23::Day23 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day23::Day23 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day24.rs b/src/solutions/day24.rs new file mode 100644 index 0000000..74be3fb --- /dev/null +++ b/src/solutions/day24.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day24 {} + +impl Solution for Day24 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 24 + } +} + +impl Day24 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day24::Day24 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day24::Day24 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/day25.rs b/src/solutions/day25.rs new file mode 100644 index 0000000..1293500 --- /dev/null +++ b/src/solutions/day25.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct Day25 {} + +impl Solution for Day25 { + fn part1( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn part2( + &self, + _input: &mut Vec, + ) -> Result, Box> { + Ok(Box::new("Ready")) + } + + fn get_day(&self) -> u8 { + 25 + } +} + +impl Day25 {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = day25::Day25 {}; + + //Complete the Challenge + let answer = challenge + .part1( + utils::get_input(challenge.get_day(), utils::InputType::Test1) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } + + #[test] + fn part2() { + let challenge = day25::Day25 {}; + + //Complete the Challenge + let answer = challenge + .part2( + utils::get_input(challenge.get_day(), utils::InputType::Test2) + .unwrap() + .as_mut(), + ) + .unwrap() + .to_string(); + + assert_eq!(answer, "Ready"); + } +} diff --git a/src/solutions/mod.rs b/src/solutions/mod.rs new file mode 100644 index 0000000..e0584a5 --- /dev/null +++ b/src/solutions/mod.rs @@ -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) -> 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(); + + 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, + pub part2: Box, + pub day: u8, + pub time: core::time::Duration, +} + +unsafe impl Send for Run {} diff --git a/src/utils.rs b/src/utils.rs new file mode 100644 index 0000000..10a4dec --- /dev/null +++ b/src/utils.rs @@ -0,0 +1,37 @@ +use std::{ + error::Error, + fs::File, + io::{prelude::*, BufReader}, +}; + +/// Enum used to specify input +#[allow(unused)] +pub enum InputType { + Test1, + Test2, + Actual, +} + +/// Function to get the input for a given day of AoC +pub fn get_input(day: u8, input: InputType) -> Result, Box> { + // Find Input File Name + let file_name = match input { + InputType::Test1 => format!("input/day{:02}_test1", day), + InputType::Test2 => format!("input/day{:02}_test2", day), + InputType::Actual => format!("input/day{:02}", day), + }; + + // Read file into buffer + let file = File::open(file_name)?; + let reader = BufReader::new(file); + + // Convert itterate buffer and return string vec + let data = reader + .lines() + .map(|s| s.unwrap_or(String::from(""))) + .collect(); + + Ok(data) +} + +/* Insert any utils you create in this file here */