refactored project structure

This commit is contained in:
2025-12-09 20:11:49 +01:00
parent 87bacd3b4c
commit 7928c2334f
69 changed files with 783 additions and 354 deletions

27
src/day06/part06a.rs Normal file
View File

@@ -0,0 +1,27 @@
pub fn solve(puzzle: String) -> u64 {
let mut iters: Vec<_> = puzzle
.lines()
.map(|line| line.split_whitespace())
.collect();
std::iter::from_fn(move || {
let column: Option<Vec<&str>> = iters
.iter_mut()
.map(|it| it.next())
.collect::<Option<Vec<_>>>();
let column = column?;
Some((
column[..column.len() - 1].iter().map(|v| v.parse::<u64>().unwrap()).collect::<Vec<_>>(),
*column.last().unwrap(),
))
}).map(|(vals, op)| {
match op {
"+" => vals.iter().sum::<u64>(),
"*" => vals.iter().product::<u64>(),
_ => unreachable!(),
}
}).sum::<u64>()
}