2023 day 9 part 2 solved

master
kwout 9 months ago
parent 23d9e8f9bf
commit 0fe4c0d032
  1. 7
      2023/9.py
  2. 4
      README.md

@ -1,11 +1,12 @@
input = [[int(i) for i in l.split()] for l in open("input.txt", 'r').read().splitlines()]
score = 0
def diff(l):
newList = [l[i+1] - l[i] for i in range(len(l)-1)]
return l[-1] + diff(newList) if set(newList) != {0} else l[-1]
score = sum(diff(l) for l in input)
score2 = sum(diff(l[::-1]) for l in input)
print(score)
print(score)
print(score2)

@ -2,8 +2,8 @@ my solutions for the [Advent of Code](https://adventofcode.com/)
in progress:\
2021: 12/25\
2022: 7/25\
2023: 3/25
2022: 8/25\
2023: 9/25
planned:\
2020\

Loading…
Cancel
Save