From: Greg Burri Date: Sun, 8 Dec 2024 17:04:29 +0000 (+0100) Subject: Simplify day 08 (2) X-Git-Url: https://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=d4c9c843c3c351c328fe4568c6e1da3668a76d7d;p=advent_of_code_2024.git Simplify day 08 (2) --- 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 => {