moved code around so each year is a package.

This commit is contained in:
2025-08-29 16:14:42 -04:00
parent 8aa7fe572f
commit 46b91dae30
67 changed files with 246 additions and 77 deletions
+7
View File
@@ -0,0 +1,7 @@
[package]
name="aoc2023"
version = "0.1.0"
edition = "2024"
[dependencies]
core = { path = "../core" }
+39
View File
@@ -0,0 +1,39 @@
use core::read_data;
fn main() {
let mut running_total = 0;
let binding = read_data("2023_01_data.txt");
let lines = binding.lines();
// let lines = "1abc2\npqr3stu8vwx\na1b2c3d4e5f\ntreb7uchet".lines();
for line in lines {
let mut working_string = String::new();
for char in line.chars() {
if char.is_numeric() {
working_string.push(char);
}
}
// take first and last chars
let this_round: u32 = match working_string.len() {
1 => {
let mut short = working_string.clone();
short.push(working_string.chars().next().unwrap());
short.parse().unwrap()
},
1 => working_string.parse().unwrap(),
_ => {
let last_char = working_string.len() - 1;
let mut short_string = String::new();
short_string.push(working_string.chars().next().unwrap());
short_string.push(working_string.chars().last().unwrap());
// println!("Unhandled ||{working_string}|| / {short_string}");
short_string.parse().unwrap()
}
};
running_total += this_round;
println!("{line:>50} found number {working_string:>10}\t{this_round}\t{running_total}");
}
println!("running total = {running_total}");
}
// 54916 too low