Class SolutionDay20
java.lang.Object
com.expedient.adventofcodejade.BaseSolution
com.expedient.adventofcodejade.solutions.year2024.SolutionDay20
-
Constructor Summary
ConstructorsConstructorDescriptionSolutionDay20(PuzzleInput input, PuzzleInput sampleInputOne, PuzzleInput sampleInputTwo) -
Method Summary
Modifier and TypeMethodDescriptionintfindCheats(Grid<Character> maze, Map<Coordinate, Integer> mazePath, int magnitude, int cheatLength) Finds the number of "cheats" that can be taken through the track which provide a time improvement of at least the given magnitudepartOne(PuzzleInput input) Finds the number of 2ns cheats that can be taken that save at least 100 ns (or 2 if we're using the sample input)partTwo(PuzzleInput input) Finds the number of 20ns cheats that can be taken that save at least 100 ns (or 2 if we're using the sample input)traverseMaze(Grid<Character> grid) Moves through the track, building a Map with each spot and its distance from the goalMethods inherited from class com.expedient.adventofcodejade.BaseSolution
getInput, run
-
Constructor Details
-
SolutionDay20
-
-
Method Details
-
traverseMaze
Moves through the track, building a Map with each spot and its distance from the goal- Parameters:
grid- the input Grid, containing characters describing a track with a Start and End- Returns:
- a Map that associates each point on the track with its distance from the end
-
findCheats
public int findCheats(Grid<Character> maze, Map<Coordinate, Integer> mazePath, int magnitude, int cheatLength) Finds the number of "cheats" that can be taken through the track which provide a time improvement of at least the given magnitude- Parameters:
maze- the Grid derived from the inputmazePath- Map containing each point on the track and its associated distance from endmagnitude- the amount of time the cheat must save to be countedcheatLength- how long the cheat is activated for (2 for part 1, 20 for part 2)- Returns:
- the number of cheats that fit the conditions
-
partOne
Finds the number of 2ns cheats that can be taken that save at least 100 ns (or 2 if we're using the sample input)- Specified by:
partOnein classBaseSolution- Parameters:
input- the PuzzleInput to be used for the solution- Returns:
- the number of cheats
-
partTwo
Finds the number of 20ns cheats that can be taken that save at least 100 ns (or 2 if we're using the sample input)- Specified by:
partTwoin classBaseSolution- Parameters:
input- the PuzzleInput to be used for the solution- Returns:
- the number of cheats
-