diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Day01.kt | 17 | ||||
-rw-r--r-- | src/Utils.kt | 13 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/Day01.kt b/src/Day01.kt new file mode 100644 index 0000000..35b4e09 --- /dev/null +++ b/src/Day01.kt @@ -0,0 +1,17 @@ +fun main() { + fun part1(input: List<String>): Int { + return input.size + } + + fun part2(input: List<String>): Int { + return input.size + } + + // test if implementation meets criteria from the description, like: + val testInput = readInput("Day01_test") + check(part1(testInput) == 1) + + val input = readInput("Day01") + println(part1(input)) + println(part2(input)) +} diff --git a/src/Utils.kt b/src/Utils.kt new file mode 100644 index 0000000..acfb72a --- /dev/null +++ b/src/Utils.kt @@ -0,0 +1,13 @@ +import java.io.File +import java.math.BigInteger +import java.security.MessageDigest + +/** + * Reads lines from the given input txt file. + */ +fun readInput(name: String) = File("src", "$name.txt").readLines() + +/** + * Converts string to md5 hash. + */ +fun String.md5(): String = BigInteger(1, MessageDigest.getInstance("MD5").digest(toByteArray())).toString(16) |