day(17): use product of iterators
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
15fccb9f5e
commit
4c07bd4f2e
1 changed files with 9 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
|||
use std::collections::HashSet;
|
||||
|
||||
use aoc_2023::*;
|
||||
use itertools::iproduct;
|
||||
|
||||
type Output1 = u32;
|
||||
type Output2 = Output1;
|
||||
|
@ -73,8 +74,10 @@ impl Day17 {
|
|||
}
|
||||
seen.insert((s.position, s.direction));
|
||||
|
||||
for steps in min_steps..=max_steps {
|
||||
for d in [left(&s.direction), right(&s.direction)] {
|
||||
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;
|
||||
}
|
||||
|
@ -82,7 +85,6 @@ impl Day17 {
|
|||
queue.push(s.step(&self.map, d, steps));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unreachable!()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue