Skip to content

Commit

Permalink
[2022/15] make scan row and max coord script args optional (default t…
Browse files Browse the repository at this point in the history
…o those used for the puzzle input)
  • Loading branch information
StarlitGhost committed Dec 13, 2024
1 parent e6c1216 commit d0e69f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
File renamed without changes.
6 changes: 4 additions & 2 deletions 2022/15/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -74,15 +75,16 @@ 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

end = timer()

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()

Expand Down

0 comments on commit d0e69f7

Please sign in to comment.