diff --git a/.idea/file.template.settings.xml b/.idea/file.template.settings.xml
index 5e3f789..6693667 100644
--- a/.idea/file.template.settings.xml
+++ b/.idea/file.template.settings.xml
@@ -8,4 +8,4 @@
-
\ No newline at end of file
+
diff --git a/src/Utils.kt b/src/Utils.kt
index b158c9f..ff225d2 100644
--- a/src/Utils.kt
+++ b/src/Utils.kt
@@ -5,30 +5,51 @@ import java.security.MessageDigest
/**
* Converts string to md5 hash.
*/
-fun String.md5() = BigInteger(1, MessageDigest.getInstance("MD5").digest(toByteArray()))
- .toString(16)
- .padStart(32, '0')
+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)
-private fun openFile(day: Int, name: String) = File("inputs/day%02d".format(day), "$name.txt")
+private fun openFile(
+ day: Int,
+ name: String,
+) = File("inputs/day%02d".format(day), "$name.txt")
/**
* Reads lines from the given input txt file.
*/
-fun readInput(day: Int, name: String) = openFile(day, name).readText().trim().lines()
+fun readInput(
+ day: Int,
+ name: String,
+) = openFile(day, name).readText().trim().lines()
-fun readInputAsString(day: Int, name: String) = openFile(day, name).readText()
-fun readInputAsInts(day: Int, name: String) = readInput(day, name).map { it.toInt() }
-fun readInputAsCommaSeparatedInts(day: Int, name: String) = openFile(day, name)
+fun readInputAsString(
+ day: Int,
+ name: String,
+) = openFile(day, name).readText()
+
+fun readInputAsInts(
+ day: Int,
+ name: String,
+) = readInput(day, name).map { it.toInt() }
+
+fun readInputAsCommaSeparatedInts(
+ day: Int,
+ name: String,
+) = openFile(day, name)
.readText()
.split(",")
.map { it.toInt() }
-fun readGraph(day: Int, name: String) = readInput(day, name).fold(mapOf>()) { currentGraph, edge ->
+fun readGraph(
+ day: Int,
+ name: String,
+) = readInput(day, name).fold(mapOf>()) { currentGraph, edge ->
val (fromVertex, toVertex) = edge.split("-")
val fromNeighbours = currentGraph.getOrDefault(fromVertex, emptySet()) + toVertex
val toNeighbours = currentGraph.getOrDefault(toVertex, emptySet()) + fromVertex
@@ -36,14 +57,24 @@ fun readGraph(day: Int, name: String) = readInput(day, name).fold(mapOf product(xs: Sequence, ys: Sequence): Sequence> =
- xs.flatMap { x -> ys.map { y -> x to y } }
+fun product(
+ xs: Sequence,
+ ys: Sequence,
+): Sequence> = xs.flatMap { x -> ys.map { y -> x to y } }
-fun product(xs: Sequence, ys: Sequence, zs: Sequence): Sequence> =
- xs.flatMap { x -> ys.flatMap { y -> zs.map { z -> Triple(x, y, z) } } }
+fun product(
+ xs: Sequence,
+ ys: Sequence,
+ zs: Sequence,
+): Sequence> = xs.flatMap { x -> ys.flatMap { y -> zs.map { z -> Triple(x, y, z) } } }
-fun product(xs: Iterable, ys: Iterable): Sequence> =
- product(xs.asSequence(), ys.asSequence())
+fun product(
+ xs: Iterable,
+ ys: Iterable,
+): Sequence> = product(xs.asSequence(), ys.asSequence())
-fun product(xs: Iterable, ys: Iterable, zs: Iterable): Sequence> =
- product(xs.asSequence(), ys.asSequence(), zs.asSequence())
+fun product(
+ xs: Iterable,
+ ys: Iterable,
+ zs: Iterable,
+): Sequence> = product(xs.asSequence(), ys.asSequence(), zs.asSequence())