mirror of
https://github.com/thib8956/advent-of-code.git
synced 2025-07-01 22:35:47 +00:00
accept input file as cmdline argument
This commit is contained in:
@ -54,7 +54,9 @@ def run_program(memory, noun, verb):
|
||||
|
||||
if __name__ == "__main__":
|
||||
tests()
|
||||
with open("input.txt") as inp:
|
||||
import sys
|
||||
infile = sys.argv[1] if len(sys.argv) > 1 else "example.txt"
|
||||
with open(infile) as inp:
|
||||
memory = [int(x) for x in inp.readline().strip().split(",")]
|
||||
# Pass a copy to avoid modifying the original memory
|
||||
print("Part 1 answer: ", run_program(memory[:], 12, 2))
|
||||
|
Reference in New Issue
Block a user