aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.kt')
-rw-r--r--src/Utils.kt8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Utils.kt b/src/Utils.kt
index acfb72a..23eacb9 100644
--- a/src/Utils.kt
+++ b/src/Utils.kt
@@ -5,7 +5,13 @@ import java.security.MessageDigest
/**
* Reads lines from the given input txt file.
*/
-fun readInput(name: String) = File("src", "$name.txt").readLines()
+fun readInputAsLines(name: String): List<String> = File("src", "$name.txt").readLines()
+
+fun readInputAsNumbers(name: String): List<Int> = readInputAsLines(name).map { it.toInt() }
+
+fun readInputAsBitLists(name: String): List<List<Int>> =
+ readInputAsLines(name)
+ .map { binaryString -> binaryString.toList().map { bit -> bit.toString().toInt() } }
/**
* Converts string to md5 hash.