Initial Setup

This commit is contained in:
Olivier David Laplante
2025-11-30 07:46:59 -05:00
commit 67d3eb6e76
7 changed files with 324 additions and 0 deletions

1
.gitignore vendored Normal file
View File

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

179
Cargo.lock generated Normal file
View File

@@ -0,0 +1,179 @@
# 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 = [
"dialoguer",
]
[[package]]
name = "bitflags"
version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
[[package]]
name = "cfg-if"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "console"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b430743a6eb14e9764d4260d4c0d8123087d504eeb9c48f2b2a5e810dd369df4"
dependencies = [
"encode_unicode",
"libc",
"once_cell",
"unicode-width",
"windows-sys",
]
[[package]]
name = "dialoguer"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25f104b501bf2364e78d0d3974cbc774f738f5865306ed128e1e0d7499c0ad96"
dependencies = [
"console",
"shell-words",
"tempfile",
"zeroize",
]
[[package]]
name = "encode_unicode"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
[[package]]
name = "errno"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys",
]
[[package]]
name = "fastrand"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
[[package]]
name = "getrandom"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
dependencies = [
"cfg-if",
"libc",
"r-efi",
"wasip2",
]
[[package]]
name = "libc"
version = "0.2.177"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
[[package]]
name = "linux-raw-sys"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
[[package]]
name = "once_cell"
version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "r-efi"
version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
[[package]]
name = "rustix"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
"windows-sys",
]
[[package]]
name = "shell-words"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
[[package]]
name = "tempfile"
version = "3.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
dependencies = [
"fastrand",
"getrandom",
"once_cell",
"rustix",
"windows-sys",
]
[[package]]
name = "unicode-width"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
[[package]]
name = "wasip2"
version = "1.0.1+wasi-0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
dependencies = [
"wit-bindgen",
]
[[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",
]
[[package]]
name = "wit-bindgen"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
[[package]]
name = "zeroize"
version = "1.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0"

7
Cargo.toml Normal file
View File

@@ -0,0 +1,7 @@
[package]
name = "aoc-2025"
version = "0.1.0"
edition = "2024"
[dependencies]
dialoguer = "0.12.0"

5
src/day1.rs Normal file
View File

@@ -0,0 +1,5 @@
pub fn run(input: &str) {
}

0
src/inputs/day1.txt Normal file
View File

32
src/main.rs Normal file
View File

@@ -0,0 +1,32 @@
use dialoguer::Select;
mod utils;
mod day1;
const CHOICES: [&str; 2] = [
"Exit",
"Day 1: ",
];
fn main() {
while let Some(choice) = get_input() {
match choice {
1 => day1::run(include_str!("inputs/day1.txt")),
_ => println!("Invalid selection")
}
}
}
fn get_input() -> Option<u32> {
let selection = Select::new()
.with_prompt("Select a day")
.items(&CHOICES)
.default(0)
.interact()
.unwrap() as u32;
match selection {
0 => None,
_ => Some(selection)
}
}

100
src/utils.rs Normal file
View File

@@ -0,0 +1,100 @@
#![allow(unused)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Direction {
Up,
Down,
Left,
Right,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Point2d {
pub x: i32,
pub y: i32,
}
impl From<(i32, i32)> for Point2d {
fn from(value: (i32, i32)) -> Self {
Point2d {
x: value.0,
y: value.1,
}
}
}
impl From<Point2d> for (i32, i32) {
fn from(value: Point2d) -> Self {
(value.x, value.y)
}
}
pub fn concat(a: u64, b: u64) -> u64 {
a * 10u64.pow(b.ilog10() + 1) + b
}
pub fn is_inbounds(bounds: (Point2d, Point2d), point: Point2d) -> bool {
(point.x >= bounds.0.x)
& (point.y >= bounds.0.y)
& (point.x <= bounds.1.x)
& (point.y <= bounds.1.y)
}
pub mod grid {
use super::Direction;
#[derive(Clone, Copy)]
pub struct Marcher {
pub direction: Direction,
pub coord: (i32, i32),
}
impl Marcher {
pub fn init(init_pos: (i32, i32), init_dir: Direction) -> Self {
Self {
direction: init_dir,
coord: init_pos,
}
}
pub fn peek(&self) -> (i32, i32) {
match self.direction {
Direction::Up => (self.coord.0 - 1, self.coord.1),
Direction::Down => (self.coord.0 + 1, self.coord.1),
Direction::Left => (self.coord.0, self.coord.1 - 1),
Direction::Right => (self.coord.0, self.coord.1 + 1),
}
}
pub fn step(&mut self) -> (i32, i32) {
let new_pos = self.peek();
self.coord = new_pos;
new_pos
}
pub fn turn_cw(&mut self) -> Direction {
match self.direction {
Direction::Up => self.direction = Direction::Right,
Direction::Right => self.direction = Direction::Down,
Direction::Down => self.direction = Direction::Left,
Direction::Left => self.direction = Direction::Up,
}
self.direction
}
pub fn turn_ccw(&mut self) -> Direction {
match self.direction {
Direction::Up => self.direction = Direction::Left,
Direction::Left => self.direction = Direction::Down,
Direction::Down => self.direction = Direction::Right,
Direction::Right => self.direction = Direction::Up,
}
self.direction
}
pub fn set_direction(&mut self, dir: Direction) -> &mut Self {
self.direction = dir;
self
}
}
}