diff --git a/src/Day01.kt b/src/Day01.kt index 284d028..d1bb47c 100644 --- a/src/Day01.kt +++ b/src/Day01.kt @@ -7,10 +7,14 @@ fun main() { return input.size } - // test if implementation meets criteria from the description, like: + // Test if implementation meets criteria from the description, like: + check(part1(listOf("test_input")) == 1) + + // Or read a large test input from the `src/Day01_test.txt` file: val testInput = readInput("Day01_test") check(part1(testInput) == 1) + // Read the input from the `src/Day01.txt` file. val input = readInput("Day01") part1(input).println() part2(input).println() diff --git a/src/Utils.kt b/src/Utils.kt index 33d5aae..7ff1419 100644 --- a/src/Utils.kt +++ b/src/Utils.kt @@ -1,12 +1,12 @@ import java.math.BigInteger import java.security.MessageDigest import kotlin.io.path.Path -import kotlin.io.path.readLines +import kotlin.io.path.readText /** * Reads lines from the given input txt file. */ -fun readInput(name: String) = Path("src/$name.txt").readLines() +fun readInput(name: String) = Path("src/$name.txt").readText().trim().lines() /** * Converts string to md5 hash.