Update things
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
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 kotlin.math.abs
|
||||
|
||||
private data class Bus(val index: Int, val id: Long)
|
||||
|
||||
@Day(13)
|
||||
class Day13(@Lines val input: Input<List<String>>) {
|
||||
class Day13(@Lines val input: List<String>) {
|
||||
|
||||
fun part1(): Int {
|
||||
val id = input.value[0].toInt()
|
||||
val id = input[0].toInt()
|
||||
|
||||
val (busId, min) = input.value[1]
|
||||
val (busId, min) = input[1]
|
||||
.splitToSequence(",")
|
||||
.filterNot { it == "x" }
|
||||
.map { it.toInt() }
|
||||
@@ -28,7 +27,7 @@ class Day13(@Lines val input: Input<List<String>>) {
|
||||
private fun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b
|
||||
|
||||
fun part2(): Long {
|
||||
val buses = input.value[1]
|
||||
val buses = input[1]
|
||||
.splitToSequence(",")
|
||||
.mapIndexedNotNull { index, bus ->
|
||||
if (bus == "x") null
|
||||
|
||||
Reference in New Issue
Block a user