1
0
Fork 0
2021/src/Utils.kt

16 lines
428 B
Kotlin
Raw Normal View History

2021-12-04 00:15:03 +01:00
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()
fun readInputAsInts(name: String) = readInput(name).map { it.toInt() }
2021-12-04 00:15:03 +01:00
/**
* Converts string to md5 hash.
*/
fun String.md5(): String = BigInteger(1, MessageDigest.getInstance("MD5").digest(toByteArray())).toString(16)