From d0e69f733f1701becc511bd3150f6da3790eb1a0 Mon Sep 17 00:00:00 2001 From: StarlitGhost <679547+StarlitGhost@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:24:58 +0000 Subject: [PATCH] [2022/15] make scan row and max coord script args optional (default to those used for the puzzle input) --- 2022/15/{test => example} | 0 2022/15/script.py | 6 ++++-- 2 files changed, 4 insertions(+), 2 deletions(-) rename 2022/15/{test => example} (100%) diff --git a/2022/15/test b/2022/15/example similarity index 100% rename from 2022/15/test rename to 2022/15/example diff --git a/2022/15/script.py b/2022/15/script.py index dd9ba41..839bfc4 100644 --- a/2022/15/script.py +++ b/2022/15/script.py @@ -60,6 +60,7 @@ def row_coverage(intersections): if __name__ == '__main__': inputs = (line.rstrip('\n') for line in open(sys.argv[1])) + pairs = [] for line in inputs: @@ -74,7 +75,8 @@ def row_coverage(intersections): start = timer() beacons = set(b for _, b in pairs) - intersections = scan(int(sys.argv[2]), pairs) + scan_row = int(sys.argv[2]) if len(sys.argv) >= 3 else 2000000 + intersections = scan(scan_row, pairs) covered = row_coverage(intersections) covered -= beacons @@ -82,7 +84,7 @@ def row_coverage(intersections): print(f'part 1: {len(covered)} {end-start:.6f} seconds') - max_coord = int(sys.argv[3]) + max_coord = int(sys.argv[3]) if len(sys.argv) >= 4 else 4000000 start = timer()