aboutsummaryrefslogtreecommitdiff
path: root/2020/09/puzzle-1.py
blob: 7676f2dec3bf9510f8c7bcc4b5ab4604ded96d9c (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
#!/usr/bin/env python3


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


def main() -> None:
	with open("input", "r", encoding="utf-8") 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()