Class SolutionDay2

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

public class SolutionDay2 extends BaseSolution
  • Constructor Details

  • Method Details

    • testAllIterationsOfReport

      public static boolean testAllIterationsOfReport(List<Integer> nums)
      I hate that this works and isn't even prohibitively slow. We're just taking the naive approach of testing every possible variant of the given report. There's probably a faster way to do it involving keeping track of how many errors there have been, but this works so whatever.
      Parameters:
      nums - the report
      Returns:
      whether any variation of the report can be good
    • isGoodReport

      public static boolean isGoodReport(List<Integer> nums)
      Overload of isGoodReport that doesn't exclude any entry from the report (-1 index is never used)
      Parameters:
      nums - the report
      Returns:
      whether the report is good
    • isGoodReport

      public static boolean isGoodReport(List<Integer> nums, int excludeIndex)
      Tells you whether the report is good. The logic will skip the given index, allowing us to test variations of the given report that have any particular element removed w/o any copy operations
      Parameters:
      nums - the report
      excludeIndex - an index of an entry to skip in the report. negative numbers will have no effect
      Returns:
      whether the report is good
    • partOne

      public Integer partOne(PuzzleInput inputUsed)
      Check is each line is a good report, and add up the count
      Specified by:
      partOne in class BaseSolution
      Parameters:
      inputUsed - the PuzzleInput to be used for the solution
      Returns:
      string containing the number of good reports
    • partTwo

      public Integer partTwo(PuzzleInput inputUsed)
      Check is each line is a good report, including ones that may be made into good reports by removing a single entry, then adds up the count
      Specified by:
      partTwo in class BaseSolution
      Parameters:
      inputUsed - the PuzzleInput to be used for the solution
      Returns:
      string containing the number of good reports