1
0

Update things

This commit is contained in:
2021-12-01 19:32:38 +01:00
parent ccfcf5a259
commit 322f8eb45a
53 changed files with 156 additions and 239 deletions
+4 -5
View File
@@ -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