Class SolutionDay18
java.lang.Object
com.expedient.adventofcodejade.BaseSolution
com.expedient.adventofcodejade.solutions.year2024.SolutionDay18
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSorts two Coordinate, Integer pairs based on the Integer value (score) in contained in each -
Constructor Summary
ConstructorsConstructorDescriptionSolutionDay18(PuzzleInput input, PuzzleInput sampleInputOne, PuzzleInput sampleInputTwo) -
Method Summary
Modifier and TypeMethodDescriptionfindBestMazeSolution(Grid<Character> grid, Coordinate startPoint) Use Dijkstra's Algorithm to find all possible shortest paths through the maze.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)static booleanGiven a Character, returns true if the character is considered traversable in the mazemazeForPointInTime(Grid<Character> field, List<Coordinate> input, int numNanoSecs) partOne(PuzzleInput input) Logic for part one of the solution.partTwo(PuzzleInput input) Logic for part two of the solution.Methods inherited from class com.expedient.adventofcodejade.BaseSolution
getInput, run
-
Constructor Details
-
SolutionDay18
-
-
Method Details
-
isTraversable
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 inputcurrent- the current locationvisited- Set of visited Coordinate, Direction pairs- Returns:
- a list of Coordinate, Integer pairs representing neighboring vertices and their weights
-
findBestMazeSolution
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 inputstartPoint- 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
-
partOne
Description copied from class:BaseSolutionLogic for part one of the solution. Must be overridden when implementing the solution.- Specified by:
partOnein classBaseSolution- Parameters:
input- the PuzzleInput to be used for the solution- Returns:
- output of this part of the solution
-
partTwo
Description copied from class:BaseSolutionLogic for part two of the solution. Must be overridden when implementing the solution.- Specified by:
partTwoin classBaseSolution- Parameters:
input- the PuzzleInput to be used for the solution- Returns:
- output of this part of the solution
-