From d4c9c843c3c351c328fe4568c6e1da3668a76d7d Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Sun, 8 Dec 2024 18:04:29 +0100 Subject: [PATCH] Simplify day 08 (2) --- src/day08.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/day08.rs b/src/day08.rs index 1aec6bd..73a945d 100644 --- a/src/day08.rs +++ b/src/day08.rs @@ -54,12 +54,10 @@ fn antinode_positions( let mut antinodes = Vec::new(); match mode { AntinodeMode::TwoPerPair => { - let (a1, a2) = ((p1x + dx, p1y + dy), (p2x - dx, p2y - dy)); - if inside(a1, limits) { - antinodes.push(a1); - } - if inside(a2, limits) { - antinodes.push(a2); + for p in [(p1x + dx, p1y + dy), (p2x - dx, p2y - dy)] { + if inside(p, limits) { + antinodes.push(p); + } } } AntinodeMode::Unlimited => { -- 2.45.2