advent_of_code_2024

Module day_12

source
Expand description

This is my solution for Advent of Code - Day 12: Garden Groups

parse_input turns the input file it a Garden as a Vec<Vec<char>>.

Garden::find_regions splits the Garden into Regions. Garden::total_fencing_cost solves part 1 using the data collected when finding the regions. Garden::total_fencing_cost_with_discount solves part 2, using Region::count_edges to find the unique edges in a region by counting corners in the perimeter.

StructsΒ§

  • Delta πŸ”’
    Implement deltas as a struct to allow some convenient consts and functions to be defined
  • Garden πŸ”’
    A grid of plots containing regions of different crops
  • Region πŸ”’
    A region that is a set of orthogonally adjacent plots in a Garden with the same crop. It stores the plots and number of units in the perimeter for use by Garden::total_fencing_cost.

EnumsΒ§

  • Side πŸ”’
    Use to track which side of the current plot has the edge being followed when walking the perimeter

FunctionsΒ§

  • parse_input πŸ”’
    Parse a text grid into a Garden
  • The entry point for running the solutions with the β€˜real’ puzzle input.

Type AliasesΒ§

  • Plot πŸ”’
    Coordinates of a plot within a Garden