Module aoc::year2022::day09

source Β·
Expand description

Β§Rope Bridge

This solution relies on the Point utility class. Two dimensional problems are common in Advent of Code, so having a decent Point (or Coord or Pos) class in your back pocket is handy.

Functions§

  • apart πŸ”’
    Two knots are considered β€œapart” if the they are not diagonally adjacent, that is the absolute distance in either x or y axes is greater than 1.
  • Converts input lines into a pair of Point and integer amount, to indicate direction and magnitude respectively. Then determines the maximum extent of the head so that we can allocate a two dimensional grid.
  • Simulate a rope length of 2
  • Simulate a rope length of 10
  • simulate πŸ”’
    Simulates a rope of arbitrary length.

Type Aliases§