aboutsummaryrefslogtreecommitdiff
path: root/2023/09/solve.py
blob: aa9ec70922a5a8f02a789ba8530b459dd4571cff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
L = [[int(n) for n in l.strip().split(" ")] for l in open("input").readlines()]


def predict(s):
    f = []
    while s:
        f.append(s[-1])
        s = [s[i] - s[i - 1] for i in range(1, len(s))]
    return sum(f)


print(sum(predict(l) for l in L))
print(sum(predict(l[::-1]) for l in L))