From 50082bb59c2618388e0a8323fd5ed7eff56b5641 Mon Sep 17 00:00:00 2001 From: Stephan Linkel <251381+norganos@users.noreply.github.com> Date: Thu, 7 Dec 2023 09:27:46 +0100 Subject: [PATCH] some minor day 7 improvements --- src/main/kotlin/de/linkel/aoc/Day07.kt | 4 ++-- src/main/kotlin/de/linkel/aoc/base/AbstractFileAdventDay.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/de/linkel/aoc/Day07.kt b/src/main/kotlin/de/linkel/aoc/Day07.kt index b6ff42c..dc414b5 100644 --- a/src/main/kotlin/de/linkel/aoc/Day07.kt +++ b/src/main/kotlin/de/linkel/aoc/Day07.kt @@ -93,8 +93,8 @@ class Day07: AbstractLinesAdventDay() { .sortedWith { a, b -> b.type.compareTo(a.type) .takeIf { it != 0 } - ?: (0..4).firstNotNullOfOrNull { i -> - a.values[i].compareTo(b.values[i]) + ?: a.values.zip(b.values).firstNotNullOfOrNull { (ca, cb) -> + ca.compareTo(cb) .takeIf { it != 0 } } ?: 0 } diff --git a/src/main/kotlin/de/linkel/aoc/base/AbstractFileAdventDay.kt b/src/main/kotlin/de/linkel/aoc/base/AbstractFileAdventDay.kt index 2cad44a..f2521c0 100644 --- a/src/main/kotlin/de/linkel/aoc/base/AbstractFileAdventDay.kt +++ b/src/main/kotlin/de/linkel/aoc/base/AbstractFileAdventDay.kt @@ -36,7 +36,7 @@ abstract class AbstractFileAdventDay: AdventDay { val result = measureTimedValue { process(part, reader) } - println("Solution is $${result.value}") + println("Solution is ${result.value}") println ("calculation took ${msFormat.format(result.duration.inWholeMicroseconds / 1000F)}ms") return result.value }