2020/Day 9/one.py

33 lines
613 B
Python
Raw Normal View History

2022-07-01 15:56:12 +02:00
#!/bin/python
def check(numbers, num):
for i in numbers:
for j in numbers:
print(f"Checking {i} + {j} = {num}")
if i + j == num:
return True
return False
def rotate(numbers, num):
del numbers[0]
numbers.append(num)
return numbers
with open("input", 'r') as input:
numbers = []
for _ in range(26):
numbers.append(int(next(input).strip()))
for num in input:
num = int(num.strip())
if not check(numbers, num):
print(num)
break
numbers = rotate(numbers, num)