main.py running all days

This commit is contained in:
Stefan Harmuth 2020-12-01 08:40:31 +01:00
parent 10a569faed
commit b5d4852d82
5 changed files with 30 additions and 5 deletions

View File

@ -1 +1,2 @@
from .inputs import *
from .output import *

2
aoclib/output.py Normal file
View File

@ -0,0 +1,2 @@
def printSolution(day, part, solution):
print(f"Solution to day {day}, part {part}: {solution}")

View File

@ -1,13 +1,17 @@
import aoclib
import sys
#my_input = [1721, 979, 366, 299, 675, 1456] # debug input
my_input = aoclib.getInputLineAsArray(1, int)
globalBreak = False
while len(my_input) > 0:
try_value = my_input.pop()
for value in my_input:
if try_value + value == 2020:
print(try_value * value)
sys.exit(0)
aoclib.printSolution(1, 1, try_value * value)
globalBreak = True
break
if globalBreak:
break

View File

@ -4,6 +4,7 @@ import sys
#my_input = [1721, 979, 366, 299, 675, 1456] # debug input
my_input = aoclib.getInputLineAsArray(1, int)
globalBreak = False
while len(my_input) > 0:
try_value = my_input.pop()
for value_1 in my_input:
@ -11,6 +12,13 @@ while len(my_input) > 0:
if value_1 == value_2:
continue
if try_value + value_1 + value_2 == 2020:
print(try_value * value_1 * value_2)
sys.exit(0)
aoclib.printSolution(1, 2, try_value * value_1 * value_2)
globalBreak = True
break
if globalBreak:
break
if globalBreak:
break

10
main.py Normal file
View File

@ -0,0 +1,10 @@
import aoclib
import os
for _, _, files in os.walk(aoclib.BASE_PATH):
for f in files:
if f.startswith('day') and f.endswith('.py'):
exec(open(f).read())
break