Skip to content

Commit

Permalink
Refresh the main Day01.kt file
Browse files Browse the repository at this point in the history
  • Loading branch information
hsz committed Nov 19, 2024
1 parent 6888a85 commit 5879ee8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Day01.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/Utils.kt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 5879ee8

Please sign in to comment.