31 lines
779 B
Python
Executable File
31 lines
779 B
Python
Executable File
import aoclib
|
|
import itertools
|
|
|
|
DAY = 1
|
|
TEST_SOLUTION_PART1 = 514579
|
|
TEST_SOLUTION_PART2 = 241861950
|
|
|
|
|
|
def getProductOf2020Sum(input_lines, combinations):
|
|
return_value = 1
|
|
for check_tuple in itertools.combinations(input_lines, combinations):
|
|
if sum(check_tuple) == 2020:
|
|
for value in list(check_tuple):
|
|
return_value *= value
|
|
|
|
break
|
|
|
|
return return_value
|
|
|
|
|
|
@aoclib.print_execution_time
|
|
def part1(test_mode=False):
|
|
my_input = aoclib.getInputAsArray(day=DAY, return_type=int, test=test_mode)
|
|
return getProductOf2020Sum(my_input, 2)
|
|
|
|
|
|
@aoclib.print_execution_time
|
|
def part2(test_mode=False):
|
|
my_input = aoclib.getInputAsArray(day=DAY, return_type=int, test=test_mode)
|
|
return getProductOf2020Sum(my_input, 3)
|