day12: cache and bool
This commit is contained in:
13
src/day12.rs
13
src/day12.rs
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user