day 19, easier than previous ones

This commit is contained in:
setop 2024-12-19 20:27:10 +01:00
parent 6e465d60aa
commit 5700e7d1e1
1 changed files with 6 additions and 0 deletions

6
d19/run.py Normal file
View File

@ -0,0 +1,6 @@
import sys
from functools import cache
f = cache(lambda s: 1 if len(s)==0 else sum(f(s[len(r):]) for r in R if s.startswith(r)))
R, I = sys.stdin.read().strip().split("\n\n") ; R = R.split(", ")
print(sum(f(i)>0 for i in I.split("\n")))
print(sum(f(i) for i in I.split("\n")))