2024/src/Utils.kt
Matej Focko a4cc41918e
chore: initial commit
Signed-off-by: Matej Focko <me@mfocko.xyz>
2024-12-01 13:13:49 +01:00

21 lines
515 B
Kotlin

import java.math.BigInteger
import java.security.MessageDigest
import kotlin.io.path.Path
import kotlin.io.path.readText
/**
* Reads lines from the given input txt file.
*/
fun readInput(name: String) = Path("src/$name.txt").readText().trim().lines()
/**
* 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)