From 40fc3368e8d70b8279158fed2547f0025a4f6aa9 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 11 Dec 2025 10:58:18 +0100 Subject: Add 2025 day 11 solutions --- 2025/11/puzzle-2.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 2025/11/puzzle-2.py (limited to '2025/11/puzzle-2.py') diff --git a/2025/11/puzzle-2.py b/2025/11/puzzle-2.py new file mode 100755 index 0000000..629c10c --- /dev/null +++ b/2025/11/puzzle-2.py @@ -0,0 +1,37 @@ +#!/usr/bin/python3 + +import functools + + +paths: dict[str, list[str]] = {} + +def main() -> None: + with open('input', 'r') as f: + for line in f.readlines(): + x, *xs = line.split() + paths[x[:-1]] = xs + + print(npaths('svr', 'out')) + + +@functools.cache +def npaths( + src: str, + dst: str, + dacp: bool = False, + fftp: bool = False, +) -> bool | int: + return ( + dacp and fftp + if src == dst else + sum(npaths( + nsrc, + dst, + dacp or src == 'dac', + fftp or src == 'fft', + ) for nsrc in paths[src]) + ) + + +if __name__ == '__main__': + main() -- cgit v1.2.3