diff --git a/d19/run.py b/d19/run.py new file mode 100644 index 0000000..a8ae506 --- /dev/null +++ b/d19/run.py @@ -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")))