diff --git a/.gitea/workflows/nightly.yaml b/.gitea/workflows/nightly.yaml new file mode 100644 index 0000000..fe8b231 --- /dev/null +++ b/.gitea/workflows/nightly.yaml @@ -0,0 +1,57 @@ +on: + schedule: + - cron: "0 18 * * *" + + +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/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml new file mode 100644 index 0000000..a7cc13a --- /dev/null +++ b/.gitea/workflows/test.yaml @@ -0,0 +1,45 @@ +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 + + 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/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..08fcbf1 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "advent_of_code_XXXX" +version = "0.1.0" +edition = "2021" + +[dependencies] +async-trait = "0.1.74" +fancy-regex = "0.14.0" +hashbrown = "0.15.1" +itertools = "0.13.0" +strum = "0.26.3" +strum_macros = "0.26.4" +tokio = {version = "1.41.1", features = ["full"]} diff --git a/create.py b/create.py new file mode 100644 index 0000000..80e836d --- /dev/null +++ b/create.py @@ -0,0 +1,12 @@ + +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".\\src\\input\\day{day:02d}", "x") + f = open(f".\\src\\input\\day{day:02d}_test1", "x") + f = open(f".\\src\\input\\day{day:02d}_test2", "x") \ No newline at end of file diff --git a/src/input/day01 b/src/input/day01 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day01_test1 b/src/input/day01_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day01_test2 b/src/input/day01_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day02 b/src/input/day02 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day02_test1 b/src/input/day02_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day02_test2 b/src/input/day02_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day03 b/src/input/day03 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day03_test1 b/src/input/day03_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day03_test2 b/src/input/day03_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day04 b/src/input/day04 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day04_test1 b/src/input/day04_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day04_test2 b/src/input/day04_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day05 b/src/input/day05 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day05_test1 b/src/input/day05_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day05_test2 b/src/input/day05_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day06 b/src/input/day06 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day06_test1 b/src/input/day06_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day06_test2 b/src/input/day06_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day07 b/src/input/day07 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day07_test1 b/src/input/day07_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day07_test2 b/src/input/day07_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day08 b/src/input/day08 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day08_test1 b/src/input/day08_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day08_test2 b/src/input/day08_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day09 b/src/input/day09 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day09_test1 b/src/input/day09_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day09_test2 b/src/input/day09_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day10 b/src/input/day10 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day10_test1 b/src/input/day10_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day10_test2 b/src/input/day10_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day11 b/src/input/day11 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day11_test1 b/src/input/day11_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day11_test2 b/src/input/day11_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day12 b/src/input/day12 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day12_test1 b/src/input/day12_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day12_test2 b/src/input/day12_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day13 b/src/input/day13 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day13_test1 b/src/input/day13_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day13_test2 b/src/input/day13_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day14 b/src/input/day14 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day14_test1 b/src/input/day14_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day14_test2 b/src/input/day14_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day15 b/src/input/day15 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day15_test1 b/src/input/day15_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day15_test2 b/src/input/day15_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day16 b/src/input/day16 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day16_test1 b/src/input/day16_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day16_test2 b/src/input/day16_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day17 b/src/input/day17 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day17_test1 b/src/input/day17_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day17_test2 b/src/input/day17_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day18 b/src/input/day18 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day18_test1 b/src/input/day18_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day18_test2 b/src/input/day18_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day19 b/src/input/day19 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day19_test1 b/src/input/day19_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day19_test2 b/src/input/day19_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day20 b/src/input/day20 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day20_test1 b/src/input/day20_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day20_test2 b/src/input/day20_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day21 b/src/input/day21 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day21_test1 b/src/input/day21_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day21_test2 b/src/input/day21_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day22 b/src/input/day22 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day22_test1 b/src/input/day22_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day22_test2 b/src/input/day22_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day23 b/src/input/day23 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day23_test1 b/src/input/day23_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day23_test2 b/src/input/day23_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day24 b/src/input/day24 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day24_test1 b/src/input/day24_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day24_test2 b/src/input/day24_test2 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day25 b/src/input/day25 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day25_test1 b/src/input/day25_test1 new file mode 100644 index 0000000..e69de29 diff --git a/src/input/day25_test2 b/src/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..911bf28 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,65 @@ +mod solutions; +mod utils; + +use std::{error::Error, time::SystemTime}; + +use solutions::*; + +#[tokio::main] +async fn main() -> Result<(), Box> { + 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 {}), + ]; + + let mut t = vec![]; + + // Run through and generate solutions + for day in days.leak() { + let task = tokio::spawn(async { day.run().unwrap() }); + t.push(task); + } + + let start_time = SystemTime::now(); + + 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..b0d208b --- /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..7e58d97 --- /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..d4d0571 --- /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..75a66fa --- /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..cb2fb84 --- /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..69ebe63 --- /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..193959b --- /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..4f5625d --- /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..440897e --- /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..cf43118 --- /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..1ebdf27 --- /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..c52afa4 --- /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..1239b6f --- /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..17c533f --- /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..ef3fa2d --- /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..ad4f610 --- /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..496b72a --- /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..f5a7b46 --- /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..e47c36a --- /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..ce72d5b --- /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..7491fb8 --- /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..e784924 --- /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..e38c818 --- /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..920f2e2 --- /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..05193fe --- /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/dayxx.rs b/src/solutions/dayxx.rs new file mode 100644 index 0000000..754bcab --- /dev/null +++ b/src/solutions/dayxx.rs @@ -0,0 +1,66 @@ +use super::Solution; + +pub struct DayXX {} + +impl Solution for DayXX { + 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 { + 0 + } +} + +impl DayXX {} + +/// Test from puzzle input +#[cfg(test)] +mod test { + use super::*; + use crate::*; + + #[test] + fn part1() { + let challenge = dayXX::DayXX {}; + + //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 = dayXX::DayXX {}; + + //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..12cccc9 --- /dev/null +++ b/src/solutions/mod.rs @@ -0,0 +1,58 @@ +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) -> Result, Box>; + fn part2(&self, input: &mut Vec) -> Result, Box>; + fn get_day(&self) -> u8; + + 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..fbe3c16 --- /dev/null +++ b/src/utils.rs @@ -0,0 +1,35 @@ +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!("src/input/day{:02}_test1", day), + InputType::Test2 => format!("src/input/day{:02}_test2", day), + InputType::Actual => format!("src/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) +}