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 bf8c0f3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions 2024/day19/solutions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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):
return not pattern or 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 bf8c0f3

Please sign in to comment.