From e5e8007197489a84d2fc3c499efe822642ba682e Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 11 Dec 2025 06:30:36 +0100 Subject: Day 11 2025 --- 2025/11/a.py | 8 +++++++- 2025/11/b.py | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 2025/11/b.py (limited to '2025/11') diff --git a/2025/11/a.py b/2025/11/a.py index 5fdb11b..cf06b6a 100644 --- a/2025/11/a.py +++ b/2025/11/a.py @@ -1,6 +1,12 @@ import fileinput +a = {} with fileinput.input() as lines: for line in lines: - ... + v, l2 = line[:-1].split(': ') + a[v] = l2.split(' ') +def np(v): + return 1 if v == 'out' else sum(np(w) for w in a[v]) + +print(np('you')) diff --git a/2025/11/b.py b/2025/11/b.py new file mode 100644 index 0000000..8fdcc8b --- /dev/null +++ b/2025/11/b.py @@ -0,0 +1,16 @@ +import fileinput +from functools import cache + +a = {} +with fileinput.input() as lines: + for line in lines: + v, l2 = line[:-1].split(': ') + a[v] = l2.split(' ') + +@cache +def np(v, d, f): + if v == 'out': + return 1 if d and f else 0 + return sum(np(w, d or v == 'dac', f or v == 'fft') for w in a[v]) + +print(np('svr', False, False)) -- cgit v1.3