Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bf8c0f3

Browse filesBrowse files
committed
Add solution to 2024-12-19
1 parent a37da74 commit bf8c0f3
Copy full SHA for bf8c0f3

File tree

Expand file treeCollapse file tree

1 file changed

+22
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-0
lines changed

‎2024/day19/solutions.py

Copy file name to clipboard
+22Lines changed: 22 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.