diff options
author | Marvin Borner | 2023-12-09 13:41:17 +0100 |
---|---|---|
committer | Marvin Borner | 2023-12-09 13:44:03 +0100 |
commit | 9f6b4d3cdd0e140769afb21a8085ac2d20dbc47f (patch) | |
tree | 4cbda1b381910bddd5702a3d67d0659d4cc2cfc2 /2023/09 | |
parent | 7ccfab448361f8bd00a6974701f35997bb03d7f6 (diff) |
AAH
Diffstat (limited to '2023/09')
-rw-r--r-- | 2023/09/solve.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/2023/09/solve.py b/2023/09/solve.py new file mode 100644 index 0000000..aa9ec70 --- /dev/null +++ b/2023/09/solve.py @@ -0,0 +1,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)) |