aboutsummaryrefslogtreecommitdiff
path: root/2025/11
diff options
context:
space:
mode:
Diffstat (limited to '2025/11')
-rw-r--r--2025/11/a.py8
-rw-r--r--2025/11/b.py16
2 files changed, 23 insertions, 1 deletions
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 @@
1import fileinput 1import fileinput
2 2
3a = {}
3with fileinput.input() as lines: 4with fileinput.input() as lines:
4 for line in lines: 5 for line in lines:
5 ... 6 v, l2 = line[:-1].split(': ')
7 a[v] = l2.split(' ')
6 8
9def np(v):
10 return 1 if v == 'out' else sum(np(w) for w in a[v])
11
12print(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 @@
1import fileinput
2from functools import cache
3
4a = {}
5with fileinput.input() as lines:
6 for line in lines:
7 v, l2 = line[:-1].split(': ')
8 a[v] = l2.split(' ')
9
10@cache
11def np(v, d, f):
12 if v == 'out':
13 return 1 if d and f else 0
14 return sum(np(w, d or v == 'dac', f or v == 'fft') for w in a[v])
15
16print(np('svr', False, False))

Generated with cgit - Back to sebastiano.tronto.net