diff options
author | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-12-09 12:00:12 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-12-09 12:00:12 +0000 |
commit | 7bc4e3f0667b04ad451fc44c3dda2f5b1a5d9164 (patch) | |
tree | 860ec1cfee7ee524b9ca9ad15b55051693347295 | |
parent | f0e81eadf75658eadbc3ce293ef6743b8fea8bc0 (diff) | |
download | aoc2023-7bc4e3f0667b04ad451fc44c3dda2f5b1a5d9164.tar.gz aoc2023-7bc4e3f0667b04ad451fc44c3dda2f5b1a5d9164.tar.xz aoc2023-7bc4e3f0667b04ad451fc44c3dda2f5b1a5d9164.zip |
much simpler
-rw-r--r-- | 9.py | 8 |
1 files changed, 1 insertions, 7 deletions
@@ -10,13 +10,7 @@ def predict_next(history: list[int]) -> int: ) -def predict_prev(history: list[int]) -> int: - if all(e == 0 for e in history): - return 0 - return history[0] - predict_prev([a - b for a, b in zip(history[1:], history[:-1])]) - - histories = [[int(e) for e in l.rstrip().split()] for l in stdin] print(sum(predict_next(history) for history in histories)) -print(sum(predict_prev(history) for history in histories)) +print(sum(predict_next(history[::-1]) for history in histories)) |