1
0
Fork 0

day(17): use product of iterators

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2023-12-17 18:11:53 +01:00
parent 15fccb9f5e
commit 4c07bd4f2e
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -1,6 +1,7 @@
use std::collections::HashSet;
use aoc_2023::*;
use itertools::iproduct;
type Output1 = u32;
type Output2 = Output1;
@ -73,14 +74,15 @@ impl Day17 {
}
seen.insert((s.position, s.direction));
for steps in min_steps..=max_steps {
for d in [left(&s.direction), right(&s.direction)] {
if !in_range(&self.map, &(s.position + d * steps)) {
continue;
}
queue.push(s.step(&self.map, d, steps));
for (steps, d) in iproduct!(
min_steps..=max_steps,
[left(&s.direction), right(&s.direction)]
) {
if !in_range(&self.map, &(s.position + d * steps)) {
continue;
}
queue.push(s.step(&self.map, d, steps));
}
}