1
0

Sort once

This commit is contained in:
Hubert Van De Walle 2020-12-05 08:18:25 +01:00
parent 23e3b517e9
commit d394c8697f

View File

@ -14,12 +14,11 @@ class Day05(@Lines val input: Input<List<String>>) {
.replace("L", "0")
.replace("R", "1")
.toInt(2)
}
}.sorted()
fun part1() = ids.maxOrNull()
fun part1() = ids.last()
fun part2() = ids.sorted()
.windowed(size = 2, step = 1)
fun part2() = ids.windowed(size = 2, step = 1)
.find { (a, b) -> b - a > 1 }!!
.first() + 1
}