From 511864e720753f1b7f3156b9ea8abcdb3d2835a1 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 9 Dec 2023 20:49:08 +0100 Subject: day 9 part 2 --- 09/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to '09') diff --git a/09/main.py b/09/main.py index 7fb235f..f53b218 100755 --- a/09/main.py +++ b/09/main.py @@ -17,8 +17,10 @@ for line in sys.stdin: derivatives.append(derivative(derivatives[-1])) prediction = 0 + sign = 1 for d in derivatives: - prediction += d[-1] + prediction += d[0] * sign + sign *= -1 output += prediction -- cgit v1.2.3