summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-12-09 20:49:08 +0100
committerlonkaars <loek@pipeframe.xyz>2023-12-09 20:49:08 +0100
commit511864e720753f1b7f3156b9ea8abcdb3d2835a1 (patch)
tree58c5f72aebc2e43591c198848ef9f2c802f4a34e
parentb81cc71523fdfe9065e34e09c24c78fe3fbdce98 (diff)
day 9 part 2HEADmaster
-rwxr-xr-x09/main.py4
1 files changed, 3 insertions, 1 deletions
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