File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
src/main/kotlin/de/ronny_h/aoc Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 11package de.ronny_h.aoc
22
3- import kotlin.io.path.Path
4- import kotlin.io.path.readText
53import kotlin.time.TimedValue
64import kotlin.time.measureTimedValue
75
@@ -13,11 +11,16 @@ abstract class AdventOfCode<T>(val year: Int, val day: Int) {
1311 val input = readInput()
1412 println (" Day $day $year - ${this ::class .simpleName} - part 1" )
1513 printAndCheck(input, ::part1, expectedPart1)
14+ println ()
1615 println (" Day $day $year - ${this ::class .simpleName} - part 2" )
1716 printAndCheck(input, ::part2, expectedPart2)
1817 }
1918
20- fun readInput () = AdventOfCode ::class .java.getResource(" /$year /Day${paddedDay()} .txt" )!! .readText().trim().lines()
19+ fun readInput (): List <String > {
20+ val inputFile = " /$year /Day${paddedDay()} .txt"
21+ return AdventOfCode ::class .java.getResource(inputFile)?.readText()?.trim()?.lines()
22+ ? : error(" The input file for day $day , year $year could not be found. Expected at '$inputFile ' in the resources folder." )
23+ }
2124
2225 private fun paddedDay (): String = day.toString().padStart(2 , ' 0' )
2326
You can’t perform that action at this time.
0 commit comments