• [^] # Re: Jour 11

    Posté par . En réponse au journal Advent of Code 2025. Évalué à 3. Dernière modification le 11 décembre 2025 à 18:38.

    Bon, je sais pas ce que j'ai merdé mais c'est en effet trivial, en 10 lignes:

    from functools import cache
    G = dict()
    for line in open(0).read().strip().split('\n'):
     p, c = line.split(":")
     G[p] = c.strip().split()
    G["out"] = []
    @cache
    def count_paths(node, target):
     return 1 if node == target else sum(count_paths(c, target) for c in G[node])
    print(count_paths("you","out"), count_paths("svr","fft")* count_paths("fft","dac")* count_paths("dac","out"))

    En 13MB et 0.05s