Class SolutionDay7
java.lang.Object
com.expedient.adventofcodejade.BaseSolution
com.expedient.adventofcodejade.solutions.year2024.SolutionDay7
-
Constructor Summary
ConstructorsConstructorDescriptionSolutionDay7(PuzzleInput input, PuzzleInput sampleInputOne, PuzzleInput sampleInputTwo) -
Method Summary
Modifier and TypeMethodDescriptionTakes a set of numbers, and for each number, applies both a multiplication and addition operation on it with the next operand, returning a set containing all the results, given that they're not above the target valuestatic booleancheckEquation(Pair<Long, List<Long>> equation, boolean partTwo) Checks whether the result can be found via any combination of operations on the operandsparseInput(PuzzleInput input) Reads the input line by line, constructing pairs of Integer results and a List of operands for eachpartOne(PuzzleInput input) Provides the sum of equations that can be found using the given operandspartTwo(PuzzleInput input) Provides the sum of equations that can be found using the given operands, allowing use of the concatenation operatorstatic LongperformRepairTask(PuzzleInput input, boolean partTwo) Finds the sum of all results that can be found via some combination of operations on the numbers providedMethods inherited from class com.expedient.adventofcodejade.BaseSolution
getInput, run
-
Constructor Details
-
SolutionDay7
-
-
Method Details
-
apply
Takes a set of numbers, and for each number, applies both a multiplication and addition operation on it with the next operand, returning a set containing all the results, given that they're not above the target value- Parameters:
nums- a set of numbersnextOperand- the next number to multiply/add to the current numberstarget- the target value that is not to be exceededpartTwo- whether to include the concatenation operator- Returns:
- a set of results that have not exceeded the target value
-
parseInput
-
checkEquation
Checks whether the result can be found via any combination of operations on the operands- Parameters:
equation- the result and operands as a pairpartTwo- whether to use the concatenation operator- Returns:
- whether the result can be found
-
performRepairTask
Finds the sum of all results that can be found via some combination of operations on the numbers provided- Parameters:
input- the PuzzleInputpartTwo- whether to use the Concatenation operator- Returns:
- the sum
-
partOne
Provides the sum of equations that can be found using the given operands- Specified by:
partOnein classBaseSolution- Parameters:
input- the PuzzleInput to be used for the solution- Returns:
- the sum of valid equations
-
partTwo
Provides the sum of equations that can be found using the given operands, allowing use of the concatenation operator- Specified by:
partTwoin classBaseSolution- Parameters:
input- the PuzzleInput to be used for the solution- Returns:
- the sum of valid equations
-