Skip to content

Commit bf8c0f3

Browse files
committed
Add solution to 2024-12-19
1 parent a37da74 commit bf8c0f3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

2024/day19/solutions.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from functools import cache
2+
3+
4+
with open("input") as f:
5+
ls = f.read().strip().split("\n")
6+
7+
stripes, _, *patterns = ls
8+
stripes = stripes.split(", ")
9+
10+
11+
@cache
12+
def is_possible(pattern, op):
13+
return not pattern or op(
14+
is_possible(pattern[len(stripe) :], op)
15+
for stripe in stripes
16+
if pattern.startswith(stripe)
17+
)
18+
19+
20+
# Part 1 + 2
21+
for op in any, sum:
22+
print(sum(is_possible(pattern, op) for pattern in patterns))

0 commit comments

Comments
 (0)