Module advent_of_code_2023::day_8
source · Expand description
This is my solution for Advent of Code - Day 8: Haunted Wasteland
Follows a map across a network of nodes. parse_input
delegates to parse_instructions
,
parse_network
, and parse_node
to represent list of Instruction
s and Network
or Node
s.
count_steps
counts the steps from a specific starting node to one that satisfies a given
predicate. count_parallel_steps
determines how long the ghosts need to cycle until they
all reach a destination, assuming they are all on a regular loop through the network.
Enums
- An instruction determining which branch to follow when moving to the next node
Functions
- Given a ghost starts at each of the nodes ending in
A
, and each follows the instructions in parallel, how many steps until they are all on a terminal node at the same time. - Follow the the list of instructions in a cycle until a destination node is reached
- Parse a line in the format e.g.
AAA = (BBB, CCC)
as a node labelledAAA
, linked toBBB
andCCC
on the left and right respectively. - The destination for part one is the specific node labelled
ZZZ
- Any node ending in
Z
counts as a destination for part 2 - The entry point for running the solutions with the ‘real’ puzzle input.