aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-12-08 16:39:06 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-12-08 16:39:06 +0100
commit9556641468675ef143bf9a08be2648e4c823b2d2 (patch)
treee59e2d5559eedfad6157e2b76ee9c9e3d9920d2e
parent6645309667a831ffcf27e0a9ef2b4c5ade60bd1d (diff)
Slightly optimize code
-rw-r--r--2024/08/puzzles.py4
1 files changed, 3 insertions, 1 deletions
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