From 5879ee88a07f33c9829459c3290a0910048d3952 Mon Sep 17 00:00:00 2001 From: Jakub Chrzanowski Date: Tue, 19 Nov 2024 15:54:04 +0100 Subject: [PATCH] Refresh the main Day01.kt file --- src/Day01.kt | 6 +++++- src/Utils.kt | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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.