Advertisement
hhoppe

Advent of code 2023 day 9

Dec 9th, 2023 (edited)
607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  1. def day9(s, *, part2=False):
  2.  
  3.   def f(a):
  4.     return 0 if not any(a) else a[0] - f(np.diff(a)) if part2 else a[-1] + f(np.diff(a))
  5.  
  6.   return sum(f(np.array(line.split(), int)) for line in s.splitlines())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement