(Cursed) Python
I solved the actual thing recursively in Rust, but I decided that wasn't cursed enough, so I present: Polynomial fitting!
import numpy.polynomial.polynomial as pol
with open("input.txt") as f:
lines = list(map(lambda l: list(map(int, l.split(" "))), f.read().split("\n")))
lo, hi = 0, 0
for line in lines:
for i in range(len(line)):
poly, (r, *_) = pol.Polynomial.fit(range(len(line)), line, full=True, deg=i)
if r < 0.0000000001:
break
lo += int(round(poly(-1)))
hi += int(round(poly(len(line))))
print(f"Part 1: {hi}")
print(f"Part 2: {lo}")