main.py running all days
This commit is contained in:
parent
10a569faed
commit
b5d4852d82
@ -1 +1,2 @@
|
|||||||
from .inputs import *
|
from .inputs import *
|
||||||
|
from .output import *
|
||||||
|
|||||||
2
aoclib/output.py
Normal file
2
aoclib/output.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
def printSolution(day, part, solution):
|
||||||
|
print(f"Solution to day {day}, part {part}: {solution}")
|
||||||
@ -1,13 +1,17 @@
|
|||||||
import aoclib
|
import aoclib
|
||||||
import sys
|
|
||||||
|
|
||||||
#my_input = [1721, 979, 366, 299, 675, 1456] # debug input
|
#my_input = [1721, 979, 366, 299, 675, 1456] # debug input
|
||||||
my_input = aoclib.getInputLineAsArray(1, int)
|
my_input = aoclib.getInputLineAsArray(1, int)
|
||||||
|
|
||||||
|
globalBreak = False
|
||||||
while len(my_input) > 0:
|
while len(my_input) > 0:
|
||||||
try_value = my_input.pop()
|
try_value = my_input.pop()
|
||||||
for value in my_input:
|
for value in my_input:
|
||||||
if try_value + value == 2020:
|
if try_value + value == 2020:
|
||||||
print(try_value * value)
|
aoclib.printSolution(1, 1, try_value * value)
|
||||||
sys.exit(0)
|
globalBreak = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if globalBreak:
|
||||||
|
break
|
||||||
|
|
||||||
@ -4,6 +4,7 @@ import sys
|
|||||||
#my_input = [1721, 979, 366, 299, 675, 1456] # debug input
|
#my_input = [1721, 979, 366, 299, 675, 1456] # debug input
|
||||||
my_input = aoclib.getInputLineAsArray(1, int)
|
my_input = aoclib.getInputLineAsArray(1, int)
|
||||||
|
|
||||||
|
globalBreak = False
|
||||||
while len(my_input) > 0:
|
while len(my_input) > 0:
|
||||||
try_value = my_input.pop()
|
try_value = my_input.pop()
|
||||||
for value_1 in my_input:
|
for value_1 in my_input:
|
||||||
@ -11,6 +12,13 @@ while len(my_input) > 0:
|
|||||||
if value_1 == value_2:
|
if value_1 == value_2:
|
||||||
continue
|
continue
|
||||||
if try_value + value_1 + value_2 == 2020:
|
if try_value + value_1 + value_2 == 2020:
|
||||||
print(try_value * value_1 * value_2)
|
aoclib.printSolution(1, 2, try_value * value_1 * value_2)
|
||||||
sys.exit(0)
|
globalBreak = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if globalBreak:
|
||||||
|
break
|
||||||
|
|
||||||
|
if globalBreak:
|
||||||
|
break
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user