2020/python/day09-b.py

23 lines
398 B
Python

import fileinput
import itertools
import sys
N = 25
numbers = []
for line in fileinput.input():
numbers.append(int(line))
for i in range(N, len(numbers)):
target = 25918798
#target=127
for j in range(i - N,i):
for k in range(j+ 1, i):
nn = numbers[j:k]
if sum(nn) == target:
print(max(nn) + min(nn))
sys.exit(0)