finish day2.1, move input reading out of day1
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user