Class SolutionDay2
java.lang.Object
com.expedient.adventofcodejade.BaseSolution
com.expedient.adventofcodejade.solutions.year2024.SolutionDay2
-
Constructor Summary
ConstructorsConstructorDescriptionSolutionDay2(PuzzleInput input, PuzzleInput sampleInputOne, PuzzleInput sampleInputTwo) -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisGoodReport(List<Integer> nums) Overload of isGoodReport that doesn't exclude any entry from the report (-1 index is never used)static booleanisGoodReport(List<Integer> nums, int excludeIndex) Tells you whether the report is good.partOne(PuzzleInput inputUsed) Check is each line is a good report, and add up the countpartTwo(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 countstatic booleantestAllIterationsOfReport(List<Integer> nums) I hate that this works and isn't even prohibitively slow.Methods inherited from class com.expedient.adventofcodejade.BaseSolution
getInput, run
-
Constructor Details
-
SolutionDay2
-
-
Method Details
-
testAllIterationsOfReport
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
-
isGoodReport
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 reportexcludeIndex- an index of an entry to skip in the report. negative numbers will have no effect- Returns:
- whether the report is good
-
partOne
Check is each line is a good report, and add up the count- Specified by:
partOnein classBaseSolution- Parameters:
inputUsed- the PuzzleInput to be used for the solution- Returns:
- string containing the number of good reports
-
partTwo
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:
partTwoin classBaseSolution- Parameters:
inputUsed- the PuzzleInput to be used for the solution- Returns:
- string containing the number of good reports
-