From 9556641468675ef143bf9a08be2648e4c823b2d2 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 8 Dec 2024 16:39:06 +0100 Subject: Slightly optimize code --- 2024/08/puzzles.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/2024/08/puzzles.py b/2024/08/puzzles.py index 87c4c46..27efbb0 100644 --- a/2024/08/puzzles.py +++ b/2024/08/puzzles.py @@ -28,7 +28,9 @@ def main() -> None: antinodes.add(a + u⃗*2) antinodes.add(b + v⃗*2) # END PART 1 START PART 2 - for i in range(1, max(w, h)): + x = int(w // abs(v⃗.real)) + 1 + y = int(h // abs(v⃗.imag)) + 1 + for i in range(1, min(x, y)): antinodes.add(a + u⃗*i) antinodes.add(b + v⃗*i) # END PART 2 -- cgit v1.2.3