This commit is contained in:
dolphinau 2025-12-01 13:03:29 +01:00
commit fc496204e7
No known key found for this signature in database
24 changed files with 2758 additions and 0 deletions

2
AoC_2025/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/target/
/input/

186
AoC_2025/Cargo.lock generated Normal file
View file

@ -0,0 +1,186 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "AoC_2025"
version = "0.1.0"
dependencies = [
"clap",
]
[[package]]
name = "anstream"
version = "0.6.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
[[package]]
name = "anstyle-parse"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys",
]
[[package]]
name = "clap"
version = "4.5.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
[[package]]
name = "colorchoice"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
[[package]]
name = "once_cell_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "proc-macro2"
version = "1.0.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
dependencies = [
"proc-macro2",
]
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "2.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
]

7
AoC_2025/Cargo.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "AoC_2025"
version = "0.1.0"
edition = "2024"
[dependencies]
clap = { version = "4.5.53", features = ["derive"] }

5
AoC_2025/README.md Normal file
View file

@ -0,0 +1,5 @@
# Advent of Code 2025
As with previous years, youll find quick access to the 2025 solutions below:
- [day 1](./src/days/day01.rs)

9
AoC_2025/src/ansi.rs Normal file
View file

@ -0,0 +1,9 @@
pub const RESET: &str = "\x1b[0m";
pub const BOLD: &str = "\x1b[1m";
pub const RED: &str = "\x1b[31m";
pub const GREEN: &str = "\x1b[32m";
pub const YELLOW: &str = "\x1b[33m";
pub const BLUE: &str = "\x1b[94m";
pub const WHITE: &str = "\x1b[97m";
pub const HOME: &str = "\x1b[H";
pub const CLEAR: &str = "\x1b[J";

22
AoC_2025/src/cli.rs Normal file
View file

@ -0,0 +1,22 @@
use clap::Parser;
use std::ops::RangeInclusive;
const DAY_RANGE: RangeInclusive<usize> = 1..=25;
fn day_in_range(d: &str) -> Result<usize, String> {
let day: usize = d.parse().map_err(|_| format!("`{d}` is not a number."))?;
if DAY_RANGE.contains(&day) {
Ok(day)
} else {
Err(format!(
"`{day}` not in range {}-{}.",
DAY_RANGE.start(),
DAY_RANGE.end()
))
}
}
#[derive(Parser)]
pub struct Cli {
#[arg(help = "day to run", value_parser = day_in_range)]
pub day: usize,
}

View file

@ -0,0 +1,17 @@
use crate::days::Solution;
pub struct Day01;
impl Solution for Day01 {
type Input = ();
fn parse(&self, data: &str) -> Self::Input {}
fn part1(&self, input: &Self::Input) -> usize {
0
}
fn part2(&self, input: &Self::Input) -> usize {
0
}
}

9
AoC_2025/src/days/mod.rs Normal file
View file

@ -0,0 +1,9 @@
pub mod day01;
pub trait Solution {
type Input;
fn parse(&self, data: &str) -> Self::Input;
fn part1(&self, input: &Self::Input) -> usize;
fn part2(&self, input: &Self::Input) -> usize;
}

3
AoC_2025/src/lib.rs Normal file
View file

@ -0,0 +1,3 @@
pub mod ansi;
pub mod cli;
pub mod days;

44
AoC_2025/src/main.rs Normal file
View file

@ -0,0 +1,44 @@
use AoC_2025::{
ansi::{BOLD, RED, RESET, YELLOW},
cli,
days::{self, Solution},
};
use clap::Parser;
use std::{fs::read_to_string, process, time::Instant};
fn run(day: usize, sol: impl Solution) {
let path = format!("input/{day:02}_day.txt");
if let Ok(data) = read_to_string(&path) {
let now = Instant::now();
let input = sol.parse(&data);
let part1 = sol.part1(&input);
let part2 = sol.part2(&input);
let elapsed = now.elapsed();
println!("{YELLOW}------------{RESET}");
println!("{BOLD}{YELLOW} Day {day:02}{RESET}");
println!("{YELLOW}------------{RESET}");
println!("Part1: {part1}");
println!("Part2: {part2}");
println!("Time: {} ns", elapsed.as_nanos());
} else {
println!("{RED}------------{RESET}");
println!("{BOLD}{RED} Day {day:02}{RESET}");
println!("{RED}------------{RESET}");
println!("Cannot read input at \"{path}\"");
}
}
fn main() {
let cli = cli::Cli::parse();
let sol = match cli.day {
1 => days::day01::Day01,
_ => {
eprintln!("Day {:02} is not implemented yet!", cli.day);
process::exit(1);
}
};
run(cli.day, sol);
}