day12: cache and bool

This commit is contained in:
2025-12-12 03:42:42 -08:00
parent fd6b0c846b
commit 845138dd2d

View File

@@ -146,13 +146,12 @@ impl PresentsProblem {
) { ) {
if let Some(solution) = self.place_next(new_t, cur + 1, cache) { if let Some(solution) = self.place_next(new_t, cur + 1, cache) {
return Some(solution); return Some(solution);
} else { }
}
}
}
}
cache.insert((cur, t.area.clone())); cache.insert((cur, t.area.clone()));
}
}
}
}
}
None None
} }
} }
@@ -237,7 +236,7 @@ mod tests {
12x5: 1 0 1 0 3 2"; 12x5: 1 0 1 0 3 2";
#[rstest] #[rstest]
#[case(EXAMPLE, 0)] #[case(EXAMPLE, 2)]
fn part1_example(#[case] input: &str, #[case] expected: u64) { fn part1_example(#[case] input: &str, #[case] expected: u64) {
assert_eq!(part1(&parse(input)), expected); assert_eq!(part1(&parse(input)), expected);
} }