Advent of Code 2023 - Day 9

Опубликовано: 30 Март 2026
на канале: Jonathan Paulson
4,632
72

I placed 11th on part 1; 11th on part 2; still 2nd overall.

Thinking about it recursively makes this problem easy. The next number is the last number plus the next number in the difference array (recursive call), or 0 if the input is all 0 (base case).

A nice trick I didn't spot: for part 2, you can just reverse the initial sequence - the previous number of the sequence is the next number of the reverse of the sequence!

Problem: https://adventofcode.com/2023/day/9
Solution: https://github.com/jonathanpaulson/Ad...