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