diff --git a/src/bin/day17.rs b/src/bin/day17.rs index 8e7457f..37df9e5 100644 --- a/src/bin/day17.rs +++ b/src/bin/day17.rs @@ -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)); } }