Expand description
This is my solution for Advent of Code - Day 19: Linen Layout
parse_input
uses parse_patterns
to turn the patterns into a tree of PatternTreeNode
s by repeatedly
using PatternTreeNode::insert
, and the designs as a list of lists of Colour
.
PatternTreeNode::count_matches
solves part one, calling PatternTreeNode::matches
for each design.
PatternTreeNode::sum_combinations
solves part one, calling PatternTreeNode::combinations
for each design.
StructsΒ§
- Pattern
Tree πNode A tree with branching factor of 5 for encoding the Set of all the possible patterns
EnumsΒ§
- Colour πAn enum for the possible towel colours
FunctionsΒ§
- parse_
designs πTurn the list of designs to match into the internal representation, one design per line. - parse_
input πSplit the input file into patterns and design on a blank line, and hand each to their parsing function - parse_
patterns πTurn the list of patterns into a tree that matches them. expected format e.g.r, wr, b, g, bwu, rb, gb, br
- The entry point for running the solutions with the βrealβ puzzle input.
Type AliasesΒ§
- Pattern
Tree πNode Ref The reference used by a node to refer to its children, and to hold a ref back to the root node in the recursive matchers.