Skip to content

Commit

Permalink
day 19
Browse files Browse the repository at this point in the history
  • Loading branch information
wimglenn committed Dec 23, 2024
1 parent f2bb468 commit 1cfc2f0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions aoc_wim/aoc2024/q19.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
--- Day 19: Linen Layout ---
https://adventofcode.com/2024/day/19
"""
from aocd import data
from functools import cache


@cache
def ways(design):
if not design:
return 1
return sum(ways(design[len(p):]) for p in patterns if design.startswith(p))


patterns, designs = data.split("\n\n")
patterns = patterns.split(", ")
results = [ways(d) for d in designs.split()]
print("answer_a:", sum(map(bool, results)))
print("answer_b:", sum(results))
12 changes: 12 additions & 0 deletions tests/2024/19/0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
r, wr, b, g, bwu, rb, gb, br

brwrr
bggr
gbbr
rrbgbr
ubwu
bwurrg
brgr
bbrgwb
6
16

0 comments on commit 1cfc2f0

Please sign in to comment.