31 lines
878 B
Python
Executable File
31 lines
878 B
Python
Executable File
#!/usr/bin/env python3
|
|
import aoclib
|
|
|
|
DAY = 1
|
|
|
|
|
|
def part1(test_mode=False):
|
|
my_input = aoclib.getInputLineAsArray(day=1, return_type=int, test=test_mode)
|
|
while len(my_input) > 0:
|
|
try_value = my_input.pop()
|
|
for value in my_input:
|
|
if try_value + value == 2020:
|
|
return try_value * value
|
|
|
|
|
|
def part2(test_mode=False):
|
|
my_input = aoclib.getInputLineAsArray(day=1, return_type=int, test=test_mode)
|
|
while len(my_input) > 0:
|
|
try_value = my_input.pop()
|
|
for value_1 in my_input:
|
|
for value_2 in my_input:
|
|
if value_1 == value_2:
|
|
continue
|
|
if try_value + value_1 + value_2 == 2020:
|
|
return try_value * value_1 * value_2
|
|
|
|
|
|
if __name__ == '__main__':
|
|
aoclib.printSolution(DAY, 1, part1())
|
|
aoclib.printSolution(DAY, 2, part2())
|