This commit is contained in:
2020-12-04 19:45:03 +01:00
parent 668449e943
commit 6011cf2b4e
5 changed files with 147 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
from typing import List
from itertools import product
from os.path import join, dirname
target = 2020
data = join(dirname(__file__), '../data.txt')
with open(data) as f:
numbers: List[int] = list(map(int, f.readlines()))
for a, b in product(numbers, numbers):
if a + b == target:
print(f'The numbers: {a} and {b}.\tSolution: {a*b}')
break
for a, b, c in product(numbers, numbers, numbers):
if a + b + c == target:
print(f'The numbers: {a}, {b} and {c}.\tSolution: {a*b*c}')
break