aboutsummaryrefslogtreecommitdiff
path: root/2020/09/puzzle-1.py
blob: f68fc2138181ea66957264743cb9fc4e6c485810 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3
from typing import List


def is_valid(nums: List[int], lp: int, up: int) -> bool:
	for i in range(lp, up):
		x = nums[up] - nums[i]
		if x in nums[lp:up] and x != nums[i]:
			return True
	return False


def main() -> None:
	with open("input", "r") as f:
		nums = list(map(int, f.readlines()))

	lp = 0
	up = 25

	while is_valid(nums, lp, up):
		lp += 1
		up += 1

	print(nums[up])


if __name__ == "__main__":
	main()