Skip to content

Commit 6d8c43b

Browse files
committed
Update SolutionTimer.kt
1 parent e69d68d commit 6d8c43b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/kotlin/sschr15/aocsolutions/SolutionTimer.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ object SolutionTimer {
4545
val start = Clock.System.now()
4646

4747
// Load the challenge class
48-
val day = if (dayString.matches("Day\\d{1,2}".toRegex())) dayString else error("Invalid day: $dayString")
49-
val dayClass = Class.forName("sschr15.aocsolutions.$day")
48+
val day = if (dayString.matches("Day\\d{1,2}.*".toRegex())) dayString else error("Invalid day: $dayString")
49+
val dayClass = Class.forName("sschr15.aocsolutions.$dayString")
5050
val challenge = dayClass.kotlin.objectInstance as Challenge
5151

5252
// Disable output (don't go logging the same thing 20 times)
@@ -86,7 +86,7 @@ object SolutionTimer {
8686
val min = times.min()
8787
val max = times.max()
8888

89-
print("Times for day ${day.substring(3)} ")
89+
print("Times for day ${day.substring(3).takeWhile { it.isDigit() }} ")
9090

9191
if (times.size > 500) {
9292
println("(${times.size} runs):")
@@ -117,7 +117,7 @@ object SolutionTimer {
117117
if (!prepFile.exists()) prepFile.createFile()
118118

119119
val textToAppend = listOf(
120-
"Day ${day.substring(3)} Preparation Times (20 runs):",
120+
"Day ${day.substring(3).takeWhile { it.isDigit() }} Preparation Times (20 runs):",
121121
"Ran at ${start.toLocalDateTime(TimeZone.UTC)} (UTC)",
122122
"Average: ${(prepTimes.sumOf { it.toDouble(DurationUnit.NANOSECONDS) } / prepTimes.size).nanoseconds}",
123123
"Min: ${prepTimes.min()}",

0 commit comments

Comments
 (0)