File tree Expand file tree Collapse file tree 1 file changed +2
-3
lines changed
src/main/kotlin/me/peckb/aoc/_2025/calendar/day03 Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,9 @@ class Day03 @Inject constructor(
1717 private fun maxJoltage (
1818 batteryArray : List <Long >,
1919 startIndex : Int = 0,
20- endIndex : Int = batteryArray.size - 1,
2120 numToEnable : Int ,
2221 ) : Long {
23- val subListIndices = startIndex .. (endIndex - (numToEnable - 1 ))
22+ val subListIndices = startIndex .. ((batteryArray.size - 1 ) - (numToEnable - 1 ))
2423
2524 val indexOfLargest = subListIndices.maxBy { i -> batteryArray[i] }
2625 val largestStartValue = batteryArray[indexOfLargest]
@@ -30,7 +29,7 @@ class Day03 @Inject constructor(
3029
3130 // if we have more batteries to flip - find the indices for those batteries and send down the new arrays
3231 val possibleStartIndices = subListIndices.filter { i -> batteryArray[i] == largestStartValue }
33- val maxSubJoltage = possibleStartIndices.maxOf { i -> maxJoltage(batteryArray.drop( i + 1 ) , numToEnable = numToEnable - 1 ) }
32+ val maxSubJoltage = possibleStartIndices.maxOf { i -> maxJoltage(batteryArray, startIndex = i + 1 , numToEnable = numToEnable - 1 ) }
3433
3534 // then add it to our value and return!
3635 return " $largestStartValue$maxSubJoltage " .toLong()
You can’t perform that action at this time.
0 commit comments