advent_of_code_2024

Module day_19

source
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 PatternTreeNodes 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Β§

  • PatternTreeNode πŸ”’
    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Β§

  • 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.