Sort once
This commit is contained in:
parent
23e3b517e9
commit
d394c8697f
@ -14,12 +14,11 @@ class Day05(@Lines val input: Input<List<String>>) {
|
|||||||
.replace("L", "0")
|
.replace("L", "0")
|
||||||
.replace("R", "1")
|
.replace("R", "1")
|
||||||
.toInt(2)
|
.toInt(2)
|
||||||
}
|
}.sorted()
|
||||||
|
|
||||||
fun part1() = ids.maxOrNull()
|
fun part1() = ids.last()
|
||||||
|
|
||||||
fun part2() = ids.sorted()
|
fun part2() = ids.windowed(size = 2, step = 1)
|
||||||
.windowed(size = 2, step = 1)
|
|
||||||
.find { (a, b) -> b - a > 1 }!!
|
.find { (a, b) -> b - a > 1 }!!
|
||||||
.first() + 1
|
.first() + 1
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user