Class SolutionDay16

java.lang.Object
com.expedient.adventofcodejade.BaseSolution
com.expedient.adventofcodejade.solutions.year2024.SolutionDay16

public class SolutionDay16 extends BaseSolution
  • Constructor Details

  • Method Details

    • isTraversable

      public static boolean isTraversable(Character c)
      Given a Character, returns true if the character is considered traversable in the maze
      Parameters:
      c - Character from the maze
      Returns:
      whether the Character is traversable
    • getNeighbors

      public static List<Pair<Coordinate,Integer>> getNeighbors(Grid<Character> grid, Coordinate current, Direction currentDirection, Set<Pair<Coordinate,Direction>> visited)
      Given the Grid, current position, current direction, and a Set of previously visited Coordinate, Direction pairs, find neighboring Coordinates and their associated weights (how much traversing to them will impact the score)
      Parameters:
      grid - Character Grid derived from the input
      current - the current location
      currentDirection - the current direction
      visited - Set of visited Coordinate, Direction pairs
      Returns:
      a list of Coordinate, Integer pairs representing neighboring vertices and their weights
    • findAllMazeSolutions

      public Map<Pair<Coordinate,Direction>,List<Pair<Coordinate,Direction>>> findAllMazeSolutions(Grid<Character> grid, Coordinate startPoint)
      Use Dijkstra's Algorithm to find all possible shortest paths through the maze. Uses the weights from the getNeighbors method to account for the fact that turns matter more than steps
      Parameters:
      grid - Character Grid derived from the puzzle input
      startPoint - Coordinate that we start at
      Returns:
      Map containing all Coordinates in the maze, each with a List of Coordinate, Direction pairs that leading to that Coordinate along optimal paths
    • partOne

      public Integer partOne(PuzzleInput input)
      Find one of the shortest possible paths through the maze with the given parameters, and then calculate its score.
      Specified by:
      partOne in class BaseSolution
      Parameters:
      input - the PuzzleInput to be used for the solution
      Returns:
      the score of one of the shortest paths through the maze
    • partTwo

      public Integer partTwo(PuzzleInput input)
      Find all shortest paths through the maze, and then figure out how many coordinates (seats) lie along those paths
      Specified by:
      partTwo in class BaseSolution
      Parameters:
      input - the PuzzleInput to be used for the solution
      Returns:
      the number of seats that lie along the path