Use pathlib for input.txt path

This commit is contained in:
2021-12-05 14:29:50 +01:00
parent 0dee47b9cc
commit 4f7907b17c
6 changed files with 39 additions and 29 deletions

View File

@@ -1,4 +1,6 @@
#!/usr/bin/python3
from pathlib import Path
def part_1(input):
result = 0
@@ -59,8 +61,8 @@ def part_2(input):
input = list()
with open('input.txt') as fp:
input = fp.readlines()
part_1(input)
part_2(input)
p = Path(__file__).with_name('input.txt')
with open(p) as f:
input = f.readlines()
part_1(input)
part_2(input)