diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-12-08 16:39:06 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-12-08 16:39:06 +0100 |
commit | 9556641468675ef143bf9a08be2648e4c823b2d2 (patch) | |
tree | e59e2d5559eedfad6157e2b76ee9c9e3d9920d2e /2024 | |
parent | 6645309667a831ffcf27e0a9ef2b4c5ade60bd1d (diff) |
Slightly optimize code
Diffstat (limited to '2024')
-rw-r--r-- | 2024/08/puzzles.py | 4 |
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 |