From cfad49c24eabba8461993027b465c772cc18338e Mon Sep 17 00:00:00 2001 From: Izan Gil <66965250+SrIzan10@users.noreply.github.com> Date: Sun, 30 Nov 2025 23:55:36 +0100 Subject: [PATCH] feat: 2025 boilerplate --- 2025/Cargo.lock | 63 ++++++++++++++++++++++++++++++++++++++++++ 2025/Cargo.toml | 2 ++ 2025/README.md | 27 ++++++++++++++++++ 2025/inputs/day01.txt | 1 + 2025/src/days/day01.rs | 17 ++++++++++++ 2025/src/days/mod.rs | 8 ++++++ 2025/src/main.rs | 22 ++++++++++++++- 2025/src/utils.rs | 6 ++++ 8 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 2025/README.md create mode 100644 2025/inputs/day01.txt create mode 100644 2025/src/days/day01.rs create mode 100644 2025/src/days/mod.rs create mode 100644 2025/src/utils.rs diff --git a/2025/Cargo.lock b/2025/Cargo.lock index 25df959..d2141aa 100644 --- a/2025/Cargo.lock +++ b/2025/Cargo.lock @@ -2,6 +2,69 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + [[package]] name = "aoc2025" version = "0.1.0" +dependencies = [ + "itertools", + "regex", +] + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "regex" +version = "1.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" diff --git a/2025/Cargo.toml b/2025/Cargo.toml index cfe6cd5..9ba671b 100644 --- a/2025/Cargo.toml +++ b/2025/Cargo.toml @@ -4,3 +4,5 @@ version = "0.1.0" edition = "2024" [dependencies] +itertools = "0.14.0" +regex = "1.12.2" diff --git a/2025/README.md b/2025/README.md new file mode 100644 index 0000000..beb78f9 --- /dev/null +++ b/2025/README.md @@ -0,0 +1,27 @@ +# Advent of Code 2025 - Rust + +## Daily Workflow + +To add a new day's solution (e.g., Day 2): + +1. **Create the Source File**: + - Copy `src/days/day01.rs` to `src/days/day02.rs`. + - Update the logic in `part1` and `part2`. + +2. **Register the Module**: + - Open `src/days/mod.rs`. + - Add `pub mod day02;` at the top. + - Add a match arm for the new day: + ```rust + 2 => day02::run(), + ``` + +3. **Add Input**: + - Create a new file `inputs/day02.txt`. + - Paste your puzzle input into it. + +4. **Run**: + - Execute the solution with: + ```bash + cargo run 2 + ``` diff --git a/2025/inputs/day01.txt b/2025/inputs/day01.txt new file mode 100644 index 0000000..8b8c6a0 --- /dev/null +++ b/2025/inputs/day01.txt @@ -0,0 +1 @@ +test input \ No newline at end of file diff --git a/2025/src/days/day01.rs b/2025/src/days/day01.rs new file mode 100644 index 0000000..a35102a --- /dev/null +++ b/2025/src/days/day01.rs @@ -0,0 +1,17 @@ +use crate::utils; + +pub fn run() { + let input = utils::read_input(1); + println!("Part 1: {}", part1(&input)); + println!("Part 2: {}", part2(&input)); +} + +fn part1(_input: &str) -> String { + // TODO: Solve part 1 + "Not implemented".to_string() +} + +fn part2(_input: &str) -> String { + // TODO: Solve part 2 + "Not implemented".to_string() +} diff --git a/2025/src/days/mod.rs b/2025/src/days/mod.rs new file mode 100644 index 0000000..a11f3c7 --- /dev/null +++ b/2025/src/days/mod.rs @@ -0,0 +1,8 @@ +pub mod day01; + +pub fn run_day(day: u8) { + match day { + 1 => day01::run(), + _ => println!("Day {} not implemented yet", day), + } +} diff --git a/2025/src/main.rs b/2025/src/main.rs index e7a11a9..edd9b53 100644 --- a/2025/src/main.rs +++ b/2025/src/main.rs @@ -1,3 +1,23 @@ +mod days; +mod utils; + +use std::env; + fn main() { - println!("Hello, world!"); + let args: Vec = env::args().collect(); + + if args.len() < 2 { + println!("Usage: cargo run "); + return; + } + + let day: u8 = match args[1].parse() { + Ok(d) => d, + Err(_) => { + println!("Invalid day number"); + return; + } + }; + + days::run_day(day); } diff --git a/2025/src/utils.rs b/2025/src/utils.rs new file mode 100644 index 0000000..04a7979 --- /dev/null +++ b/2025/src/utils.rs @@ -0,0 +1,6 @@ +use std::fs; + +pub fn read_input(day: u8) -> String { + let path = format!("inputs/day{:02}.txt", day); + fs::read_to_string(&path).unwrap_or_else(|_| panic!("Could not read file: {}", path)) +}