From 5700e7d1e1ef10fdb9a78cd1060a6be5c445e9dc Mon Sep 17 00:00:00 2001 From: setop Date: Thu, 19 Dec 2024 20:27:10 +0100 Subject: [PATCH] day 19, easier than previous ones --- d19/run.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 d19/run.py 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")))