1
0
Fork 0

day(01): refactor part 2

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2021-12-04 15:16:12 +01:00
parent 4186cf4815
commit e3e721b6b4

View file

@ -4,7 +4,7 @@ import readInputAsInts
fun main() {
fun part1(input: List<Int>): Int = input.windowed(2).count { it[0] < it[1] }
fun part2(input: List<Int>): Int = part1(input.windowed(3).map { it.sum() }.toList())
fun part2(input: List<Int>): Int = input.windowed(4).count { it[0] < it[3] }
val testInput = readInputAsInts(1, "test_input")
val input = readInputAsInts(1, "input")