finish day2.1, move input reading out of day1

This commit is contained in:
2021-01-20 19:40:42 +01:00
parent ce766388fd
commit 3de439fa41
4 changed files with 1086 additions and 7 deletions
+2 -7
View File
@@ -1,8 +1,9 @@
import pytest
from itertools import combinations
from typing import Tuple, List
from math import prod
from utils import read_input_data
def test_find_sum_two():
test_string = """
@@ -27,12 +28,6 @@ def test_find_sum_three():
assert find_sum(intify_input(test_string), 3) == (979, 366, 675)
def read_input_data(path: str) -> str:
with open(path, 'r') as f:
data = f.read()
return data
def find_sum(data: List[int], n_summands: int = 2, target: int = 2020) -> Tuple[int, int]:
for combo in combinations(data, n_summands):
if sum(combo) == target: