Created
December 9, 2023 11:12
-
-
Save haakonvt/46b109aa6b36af8801a7d39550195b23 to your computer and use it in GitHub Desktop.
AOC 2023, day 9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def diff_inplace(arr): | |
for idx in range(arr.shape[1], 2, -1): | |
arr[:,:idx-1] = np.diff(arr[:,:idx]) | |
return arr.sum() | |
p1 = np.array([l.split() for l in inp.splitlines()], dtype=np.int32) | |
p2 = np.fliplr(p1.copy()) | |
print(diff_inplace(p1), diff_inplace(p2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment