Class SolutionDay18

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

public class SolutionDay18 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, Set<Coordinate> visited)
      Given the Grid, current position, 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
      visited - Set of visited Coordinate, Direction pairs
      Returns:
      a list of Coordinate, Integer pairs representing neighboring vertices and their weights
    • findBestMazeSolution

      public Map<Coordinate,Coordinate> findBestMazeSolution(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
      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 Coordinates leading to that Coordinate along optimal paths
    • mazeForPointInTime

      public Grid<Character> mazeForPointInTime(Grid<Character> field, List<Coordinate> input, int numNanoSecs)
    • partOne

      public Object partOne(PuzzleInput input)
      Description copied from class: BaseSolution
      Logic for part one of the solution. Must be overridden when implementing the solution.
      Specified by:
      partOne in class BaseSolution
      Parameters:
      input - the PuzzleInput to be used for the solution
      Returns:
      output of this part of the solution
    • partTwo

      public Object partTwo(PuzzleInput input)
      Description copied from class: BaseSolution
      Logic for part two of the solution. Must be overridden when implementing the solution.
      Specified by:
      partTwo in class BaseSolution
      Parameters:
      input - the PuzzleInput to be used for the solution
      Returns:
      output of this part of the solution