Class SolutionDay20

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

public class SolutionDay20 extends BaseSolution
  • Constructor Details

  • Method Details

    • traverseMaze

      public Map<Coordinate,Integer> traverseMaze(Grid<Character> grid)
      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 input
      mazePath - Map containing each point on the track and its associated distance from end
      magnitude - the amount of time the cheat must save to be counted
      cheatLength - 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

      public Integer partOne(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)
      Specified by:
      partOne in class BaseSolution
      Parameters:
      input - the PuzzleInput to be used for the solution
      Returns:
      the number of cheats
    • partTwo

      public Integer 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)
      Specified by:
      partTwo in class BaseSolution
      Parameters:
      input - the PuzzleInput to be used for the solution
      Returns:
      the number of cheats