mirror of
https://github.com/thib8956/advent-of-code.git
synced 2025-08-24 08:21:57 +00:00
accept input file as cmdline argument
This commit is contained in:
@@ -40,5 +40,7 @@ def part2(infile):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
part1("./input.txt")
|
||||
part2("./input.txt")
|
||||
import sys
|
||||
infile = sys.argv[1] if len(sys.argv) > 1 else "example.txt"
|
||||
part1(infile)
|
||||
part2(infile)
|
||||
|
@@ -39,4 +39,6 @@ def main(input_file):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main("input.txt")
|
||||
import sys
|
||||
infile = sys.argv[1] if len(sys.argv) > 1 else "example.txt"
|
||||
main(infile)
|
||||
|
@@ -64,4 +64,6 @@ def main(input_file):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main("input.txt")
|
||||
import sys
|
||||
infile = sys.argv[1] if len(sys.argv) > 1 else "example.txt"
|
||||
main(infile)
|
||||
|
@@ -94,4 +94,6 @@ def main(input_file):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main("input.txt")
|
||||
import sys
|
||||
infile = sys.argv[1] if len(sys.argv) > 1 else "example.txt"
|
||||
main(infile)
|
||||
|
@@ -35,7 +35,7 @@ def main(infile):
|
||||
print(res)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main("input.txt")
|
||||
import sys
|
||||
infile = sys.argv[1] if len(sys.argv) > 1 else "example.txt"
|
||||
main(infile)
|
||||
|
@@ -23,4 +23,6 @@ def main(infile):
|
||||
print(f"Part 2, {res}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main("input.txt")
|
||||
import sys
|
||||
infile = sys.argv[1] if len(sys.argv) > 1 else "example.txt"
|
||||
main(infile)
|
||||
|
@@ -31,4 +31,4 @@ def rotate(l):
|
||||
for j in range(256):
|
||||
numbers = rotate(numbers)
|
||||
numbers[6] += numbers[8]
|
||||
print(f'DAY {j+1} AMOUNT OF FISH: {sum(numbers)}')
|
||||
print(f'DAY {j+1} AMOUNT OF FISH: {sum(numbers)}')
|
||||
|
@@ -26,8 +26,10 @@ def part2(crabs):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open("input.txt") as infile:
|
||||
crabs = [int(x) for x in infile.readline().split(",")]
|
||||
import sys
|
||||
infile = sys.argv[1] if len(sys.argv) > 1 else "example.txt"
|
||||
with open(infile) as f:
|
||||
crabs = [int(x) for x in f.readline().split(",")]
|
||||
part1(crabs)
|
||||
part2(crabs)
|
||||
|
||||
|
@@ -43,4 +43,6 @@ def main(infile):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main("input.txt")
|
||||
import sys
|
||||
infile = sys.argv[1] if len(sys.argv) > 1 else "example.txt"
|
||||
main(infile)
|
||||
|
Reference in New Issue
Block a user