Skip to content

Commit

Permalink
Add solution to 2024-12-19
Browse files Browse the repository at this point in the history
  • Loading branch information
fuglede committed Dec 19, 2024
1 parent a37da74 commit 3b35754
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions 2024/day19/solutions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from functools import cache


with open("input") as f:
ls = f.read().strip().split("\n")

stripes, _, *patterns = ls
stripes = stripes.split(", ")


@cache
def is_possible(pattern, op):
if not pattern:
return 1
return op(
is_possible(pattern[len(stripe) :], op)
for stripe in stripes
if pattern.startswith(stripe)
)


# Part 1 + 2
for op in any, sum:
print(sum(is_possible(pattern, op) for pattern in patterns))

0 comments on commit 3b35754

Please sign in to comment.