aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.kt
diff options
context:
space:
mode:
authortchojnacki <tomaszchojnacki2001@gmail.com>2022-08-10 21:01:47 +0200
committertchojnacki <tomaszchojnacki2001@gmail.com>2022-08-10 21:01:47 +0200
commit5ef64073bbb183dd425ffa360d080ca58a1c08e1 (patch)
tree9a108a0ed6d0ee7bb6799dc2260cebef2fb96723 /src/Utils.kt
parent5a4e32c427862238fd092cbc28be4622d1552a72 (diff)
downloadgleam_aoc2020-5ef64073bbb183dd425ffa360d080ca58a1c08e1.tar.gz
gleam_aoc2020-5ef64073bbb183dd425ffa360d080ca58a1c08e1.zip
Refactor all days to provide better encapsulation
Diffstat (limited to 'src/Utils.kt')
-rw-r--r--src/Utils.kt20
1 files changed, 0 insertions, 20 deletions
diff --git a/src/Utils.kt b/src/Utils.kt
index e245554..f0a420b 100644
--- a/src/Utils.kt
+++ b/src/Utils.kt
@@ -1,31 +1,11 @@
import java.io.File
-/**
- * Reads lines from the given input txt file.
- * @param name name of the file
- * @return list of strings containing line contents
- */
fun readInputAsLines(name: String): List<String> = File("src", "$name.txt").readLines()
-/**
- * Returns a string of contents of the given input txt file.
- * @param name name of the file
- * @return contents of file as string
- */
fun readInputAsString(name: String): String = File("src", "$name.txt").readText()
-/**
- * Read lines from the given input txt file and convert them to decimal numbers.
- * @param name name of the file
- * @return list of ints containing numbers from each of file's lines
- */
fun readInputAsNumbers(name: String): List<Int> = readInputAsLines(name).map(String::toInt)
-/**
- * Read lines from the given input txt file containing binary numbers and convert them to lists of bits.
- * @param name name of the file
- * @return list of lists of ints, where each inner list represents bits of one line of input
- */
fun readInputAsBitLists(name: String): List<List<Int>> =
readInputAsLines(name)
.map { binaryString -> binaryString.toList().map { bit -> bit.toString().toInt() } }