Day 17: no longer hardcode upper search bounds

This commit is contained in:
kageru 2021-12-17 21:52:42 +01:00
parent 66bc3c6d42
commit 95e4a6f8cc
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -40,7 +40,7 @@ fn find_hits(target: &TargetArea) -> Vec<isize> {
// Doing y in the outer loop and x in the inner would allow us to call last() instead of max()
// in part1, however, for reasons unknown to me, that makes this function 20% slower.
(1..=*target.0.end())
.flat_map(move |x| (*target.1.start()..250).map(move |y| (x, y)))
.flat_map(move |x| (*target.1.start()..-target.1.start()).map(move |y| (x, y)))
.filter_map(|(startx, starty)| {
let mut probe = ((startx, starty), (0, 0));
loop {