Initial commit

This commit is contained in:
OMGeeky
2022-12-11 14:09:58 +01:00
committed by GitHub
commit 49423a1f42
15 changed files with 827 additions and 0 deletions

17
src/Day01.kt Normal file
View File

@@ -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")
part1(input).println()
part2(input).println()
}

21
src/Utils.kt Normal file
View File

@@ -0,0 +1,21 @@
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() = BigInteger(1, MessageDigest.getInstance("MD5").digest(toByteArray()))
.toString(16)
.padStart(32, '0')
/**
* The cleaner shorthand for printing output.
*/
fun Any?.println() = println(this)