1
0
2020-12-05 08:18:25 +01:00

30 lines
703 B
Kotlin

package be.vandewalleh.aoc.days
import be.vandewalleh.aoc.utils.input.Day
import be.vandewalleh.aoc.utils.input.Input
import be.vandewalleh.aoc.utils.input.Lines
import be.vandewalleh.aoc.utils.input.createDay
@Day(5)
class Day05(@Lines val input: Input<List<String>>) {
private val ids = input.value.map {
it.replace("F", "0")
.replace("B", "1")
.replace("L", "0")
.replace("R", "1")
.toInt(2)
}.sorted()
fun part1() = ids.last()
fun part2() = ids.windowed(size = 2, step = 1)
.find { (a, b) -> b - a > 1 }!!
.first() + 1
}
fun main() = with(createDay<Day05>()) {
println(part1())
println(part2())
}