• # recursion

    Posté par . En réponse au message Advent of Code 2023 : Day 9. Évalué à 3.

    Pour ma part, le jour le plus facile depuis le début

    import sys
    L = [list(map(int,l.split(' '))) for l in sys.stdin.read().splitlines()]
    def extrapolate(L):
     if all(a == 0 for a in L):
     return L+[0]
     M = [b-a for a,b in zip(L,L[1:])]
     return L+[L[-1]+extrapolate(M)[-1]]
    print(sum(extrapolate(l)[-1] for l in L))