feat: day1

This commit is contained in:
2025-12-06 14:23:03 +00:00
parent c906d26046
commit d6a3b812eb
12 changed files with 9622 additions and 0 deletions

1
Day1/P1/.gitignore vendored Normal file
View File

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

7
Day1/P1/Cargo.lock generated Normal file
View File

@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "P1"
version = "0.1.0"

6
Day1/P1/Cargo.toml Normal file
View File

@@ -0,0 +1,6 @@
[package]
name = "P1"
version = "0.1.0"
edition = "2024"
[dependencies]

10
Day1/P1/example Normal file
View File

@@ -0,0 +1,10 @@
L68
L30
R48
L5
R60
L55
L1
L99
R14
L82

31
Day1/P1/src/main.rs Normal file
View File

@@ -0,0 +1,31 @@
use std::fs;
fn main() {
println!("Day 1P1");
let contents = fs::read_to_string("test").expect("input not found");
let mut value = 50;
let mut hits = 0;
for line in contents.strip_suffix("\n").unwrap().split("\n") {
let mut line_iter = line.chars();
let mut left = true;
match line_iter.next().unwrap() {
'R' => {
left = false;
}
'L' => {}
_ => panic!("What the actual fuck"),
}
let turns_str = line_iter.as_str();
let turns: i64 = turns_str.parse().unwrap();
// There's probably a rust way to not mess with the types here
let dir = match left {
true => -1,
false => 1,
};
value = (value + turns * dir) % 100;
if value == 0 {
hits += 1;
}
}
println!("Yipee {hits}")
}

4753
Day1/P1/test Normal file

File diff suppressed because it is too large Load Diff