advent-of-code/src/Utils.kt

22 lines
471 B
Kotlin
Raw Normal View History

2023-11-17 10:37:33 +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()
/**
* 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)