diff --git a/src/main/kotlin/biz/koziolek/adventofcode/year2023/day08/day8.kt b/src/main/kotlin/biz/koziolek/adventofcode/year2023/day08/day8.kt index 30388d5..2e3a7b6 100644 --- a/src/main/kotlin/biz/koziolek/adventofcode/year2023/day08/day8.kt +++ b/src/main/kotlin/biz/koziolek/adventofcode/year2023/day08/day8.kt @@ -105,7 +105,7 @@ data class WastelandNode(val id: String) { } fun parseWastelandMap(lines: List): WastelandMap { - val instructions = lines.first + val instructions = lines.first() val regex = Regex("(?[A-Z0-9]+) = \\((?[A-Z0-9]+), (?[A-Z0-9]+)\\)") val nodes = lines diff --git a/src/main/kotlin/biz/koziolek/adventofcode/year2023/day09/day9.kt b/src/main/kotlin/biz/koziolek/adventofcode/year2023/day09/day9.kt index eb65d80..52050ea 100644 --- a/src/main/kotlin/biz/koziolek/adventofcode/year2023/day09/day9.kt +++ b/src/main/kotlin/biz/koziolek/adventofcode/year2023/day09/day9.kt @@ -19,28 +19,28 @@ fun parseOasisReport(lines: Iterable): OasisReport = .let { OasisReport(it) } fun predictNextValue(history: List): Int = - extrapolateHistory(history).first.last + extrapolateHistory(history).first().last() fun predictPreviousValue(history: List): Int = - extrapolateHistoryBackwards(history).first.first + extrapolateHistoryBackwards(history).first().first() internal fun extrapolateHistory(history: List): List> { val reduced = reduceHistory(history) - val lastRowExtended = reduced.last + 0 + val lastRowExtended = reduced.last() + 0 return reduced .dropLast(1) .foldRight(listOf(lastRowExtended)) { ints, acc -> - val newRow = ints + (ints.last + acc.first.last) + val newRow = ints + (ints.last() + acc.first().last()) listOf(newRow) + acc } } internal fun extrapolateHistoryBackwards(history: List): List> { val reduced = reduceHistory(history) - val lastRowExtended = listOf(0) + reduced.last + val lastRowExtended = listOf(0) + reduced.last() return reduced .dropLast(1) .foldRight(listOf(lastRowExtended)) { ints, acc -> - val newRow = listOf(ints.first - acc.first.first) + ints + val newRow = listOf(ints.first() - acc.first().first()) + ints listOf(newRow) + acc } }