Tidied AOC XXXX
All checks were successful
Continuous integration / Check (push) Successful in 49s
Continuous integration / Test Suite (push) Successful in 51s
Continuous integration / Rustfmt (push) Successful in 36s
Continuous integration / build (push) Successful in 49s
/ Check (push) Successful in 50s
/ Test Suite (push) Successful in 52s
/ Rustfmt (push) Successful in 37s
/ Clippy (push) Successful in 51s
/ build (push) Successful in 53s

This commit is contained in:
Luke Else 2024-11-21 05:30:44 +00:00
parent bf2205c257
commit 0b35b8f623
106 changed files with 95 additions and 97 deletions

View File

@ -4,10 +4,4 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [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"]} tokio = {version = "1.41.1", features = ["full"]}

View File

@ -1,4 +1,5 @@
for day in range(1, 26): for day in range(1, 26):
boilerplate = open(".\\src\\solutions\\dayxx.rs", "r").read() boilerplate = open(".\\src\\solutions\\dayxx.rs", "r").read()
boilerplate = boilerplate.replace("0", str(day)) boilerplate = boilerplate.replace("0", str(day))
@ -7,6 +8,6 @@ for day in range(1, 26):
new_code = open(f".\\src\\solutions\\day{day:02d}.rs", "w") new_code = open(f".\\src\\solutions\\day{day:02d}.rs", "w")
new_code.write(boilerplate) new_code.write(boilerplate)
f = open(f".\\src\\input\\day{day:02d}", "x") f = open(f".\\input\\day{day:02d}", "x")
f = open(f".\\src\\input\\day{day:02d}_test1", "x") f = open(f".\\input\\day{day:02d}_test1", "x")
f = open(f".\\src\\input\\day{day:02d}_test2", "x") f = open(f".\\input\\day{day:02d}_test2", "x")

View File

@ -7,44 +7,47 @@ use solutions::*;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> { async fn main() -> Result<(), Box<dyn Error>> {
let days: Vec<Box<dyn Solution + Sync>> = vec![ /* Uncomment these before the start of each day! */
let days: Vec<Box<dyn Solution>> = vec![
Box::new(day01::Day01 {}), Box::new(day01::Day01 {}),
Box::new(day02::Day02 {}), // Box::new(day02::Day02 {}),
Box::new(day03::Day03 {}), // Box::new(day03::Day03 {}),
Box::new(day04::Day04 {}), // Box::new(day04::Day04 {}),
Box::new(day05::Day05 {}), // Box::new(day05::Day05 {}),
Box::new(day06::Day06 {}), // Box::new(day06::Day06 {}),
Box::new(day07::Day07 {}), // Box::new(day07::Day07 {}),
Box::new(day08::Day08 {}), // Box::new(day08::Day08 {}),
Box::new(day09::Day09 {}), // Box::new(day09::Day09 {}),
Box::new(day10::Day10 {}), // Box::new(day10::Day10 {}),
Box::new(day11::Day11 {}), // Box::new(day11::Day11 {}),
Box::new(day12::Day12 {}), // Box::new(day12::Day12 {}),
Box::new(day13::Day13 {}), // Box::new(day13::Day13 {}),
Box::new(day14::Day14 {}), // Box::new(day14::Day14 {}),
Box::new(day15::Day15 {}), // Box::new(day15::Day15 {}),
Box::new(day16::Day16 {}), // Box::new(day16::Day16 {}),
Box::new(day17::Day17 {}), // Box::new(day17::Day17 {}),
Box::new(day18::Day18 {}), // Box::new(day18::Day18 {}),
Box::new(day19::Day19 {}), // Box::new(day19::Day19 {}),
Box::new(day20::Day20 {}), // Box::new(day20::Day20 {}),
Box::new(day21::Day21 {}), // Box::new(day21::Day21 {}),
Box::new(day22::Day22 {}), // Box::new(day22::Day22 {}),
Box::new(day23::Day23 {}), // Box::new(day23::Day23 {}),
Box::new(day24::Day24 {}), // Box::new(day24::Day24 {}),
Box::new(day25::Day25 {}), // Box::new(day25::Day25 {}),
]; ];
// Vector to store every solution as a thread handle
let mut t = vec![]; let mut t = vec![];
// Run through and generate solutions // Run through and construct solution objects
for day in days.leak() { for day in days {
let task = tokio::spawn(async { day.run().unwrap() }); let task = tokio::spawn(async move { day.run().unwrap() });
t.push(task); t.push(task);
} }
let start_time = SystemTime::now(); let start_time = SystemTime::now();
// When thread is awaited, the solution is run
let mut days = vec![]; let mut days = vec![];
for thread in t { for thread in t {
days.push(thread.await?); days.push(thread.await?);

View File

@ -6,14 +6,14 @@ impl Solution for Day01 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day02 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day03 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day04 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day05 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day06 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day07 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day08 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day09 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day10 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day11 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day12 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day13 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day14 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day15 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day16 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day17 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day18 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day19 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day20 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day21 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

View File

@ -6,14 +6,14 @@ impl Solution for Day22 {
fn part1( fn part1(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }
fn part2( fn part2(
&self, &self,
_input: &mut Vec<String>, _input: &mut Vec<String>,
) -> Result<Box<dyn std::fmt::Display + Sync>, Box<dyn std::error::Error>> { ) -> Result<Box<dyn std::fmt::Display>, Box<dyn std::error::Error>> {
Ok(Box::new("Ready")) Ok(Box::new("Ready"))
} }

Some files were not shown because too many files have changed in this diff Show More