fix runner

This commit is contained in:
Tyrel Souza 2023-12-02 23:12:04 -05:00
parent dfe6dda514
commit f9a7a56acf
No known key found for this signature in database
GPG Key ID: F3614B02ACBE438E
8 changed files with 32 additions and 19 deletions

View File

@ -7,6 +7,7 @@ new:
touch full/day{{ DAY }}.txt
touch samples/day{{ DAY }}.txt
run:
/usr/bin/env python3 python/day{{ DAY }}.py

View File

@ -18,6 +18,8 @@ def main():
with shared.elapsed_timer() as elapsed:
part1(rows)
print("🕒", elapsed())
rows = [row for row in shared.load_rows(1,True)]
with shared.elapsed_timer() as elapsed:
part2(rows)
print("🕒", elapsed())

View File

@ -55,8 +55,9 @@ def part2(rows):
def main():
rows = [row for row in shared.load_rows(1)]
with shared.elapsed_timer() as elapsed:
#part1(rows)
part1(rows)
print("🕒", elapsed())
rows = [row for row in shared.load_rows(1, True)]
with shared.elapsed_timer() as elapsed:
part2(rows)
print("🕒", elapsed())

View File

@ -54,6 +54,8 @@ def main():
with shared.elapsed_timer() as elapsed:
part1(rows)
print("🕒", elapsed())
rows = [row for row in shared.load_rows(2, True)]
with shared.elapsed_timer() as elapsed:
part2(rows)
print("🕒", elapsed())

View File

@ -30,11 +30,18 @@ def minmax(l):
return min(l), max(l)
def load_rows(day):
return [row for row in load(day)]
def load_rows(day, part2=False):
return [row for row in load(day,part2)]
def load(day):
def load(day, part2=False):
if part2:
path = Path(get_fname(day)+".part2")
try:
return path.read_text().rstrip().split("\n")
except FileNotFoundError:
# No part 2 file, use first file
pass
path = Path(get_fname(day))
return path.read_text().rstrip().split("\n")
@ -43,9 +50,9 @@ def get_fname(day: int) -> str:
import sys
if sys.argv[-1] == "--sample":
return f"../samples/day{day:02}.txt"
return f"samples/day{day:02}.txt"
else:
return f"../full/day{day:02}.txt"
return f"full/day{day:02}.txt"
#############

View File

@ -1,4 +0,0 @@
1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet

View File

@ -1,7 +1,4 @@
two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen
1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet

View File

@ -0,0 +1,7 @@
two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen