fix failing tests

This commit is contained in:
ktims committed 2026-12-02 13:51:10 -07:00
1 parent b9478fbb6b
commit ba83989539
14 files changed
+51 -149

No files matched your search

+4 -21
View File
@@ -59,12 +59,7 @@ fn parse(input: &str) -> (Grid<u64>, Vec<Op>) {
.map(|l| l.split_ascii_whitespace().collect_vec())
.collect_vec();
let ops = rows
.pop()
.unwrap()
.iter()
.map(|op| Op::from(*op))
.collect_vec();
let ops = rows.pop().unwrap().iter().map(|op| Op::from(*op)).collect_vec();
let mut grid = Grid::with_shape(rows[0].len(), rows.len(), 0);
for (y, r) in rows.iter().enumerate() {
@@ -109,11 +104,7 @@ fn parse2(input: &str) -> (Grid<Vec<char>>, Vec<Op>) {
.map(|(i, _c)| i)
.collect_vec();
let col_lengths = col_starts
.iter()
.tuple_windows()
.map(|(l, r)| r - l - 1)
.collect_vec();
let col_lengths = col_starts.iter().tuple_windows().map(|(l, r)| r - l - 1).collect_vec();
let split_rows = rows
.iter()
@@ -225,11 +216,7 @@ fn part2_walk(g: &Grid<u8>) -> u64 {
digits = 0;
// this was a last col, so reduce and accumulate
if last_col {
accum += cur_values
.iter()
.cloned()
.reduce(|l, r| cur_op.f(&l, &r))
.unwrap_or(0);
accum += cur_values.iter().cloned().reduce(|l, r| cur_op.f(&l, &r)).unwrap_or(0);
// clear the state
cur_values.clear();
last_col = false;
@@ -241,11 +228,7 @@ fn part2_walk(g: &Grid<u8>) -> u64 {
cur_values.push(cur_value);
}
// accumulate the final result
accum += cur_values
.iter()
.cloned()
.reduce(|l, r| cur_op.f(&l, &r))
.unwrap_or(0);
accum += cur_values.iter().cloned().reduce(|l, r| cur_op.f(&l, &r)).unwrap_or(0);
return accum;
}
}