aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomasz Chojnacki <tomekch6@gmail.com>2021-12-01 18:02:41 +0100
committerTomasz Chojnacki <tomekch6@gmail.com>2021-12-01 18:02:41 +0100
commite121c204d6d899dd6f421b709d57de4d4e5ff82b (patch)
tree520bf6725d58b3b95c82c512aebf256ba14020a5 /src
downloadgleam_aoc2020-e121c204d6d899dd6f421b709d57de4d4e5ff82b.tar.gz
gleam_aoc2020-e121c204d6d899dd6f421b709d57de4d4e5ff82b.zip
Initial commit
Diffstat (limited to 'src')
-rw-r--r--src/Day01.kt17
-rw-r--r--src/Utils.kt13
2 files changed, 30 insertions, 0 deletions
diff --git a/src/Day01.kt b/src/Day01.kt
new file mode 100644
index 0000000..35b4e09
--- /dev/null
+++ b/src/Day01.kt
@@ -0,0 +1,17 @@
+fun main() {
+ fun part1(input: List<String>): Int {
+ return input.size
+ }
+
+ fun part2(input: List<String>): Int {
+ return input.size
+ }
+
+ // test if implementation meets criteria from the description, like:
+ val testInput = readInput("Day01_test")
+ check(part1(testInput) == 1)
+
+ val input = readInput("Day01")
+ println(part1(input))
+ println(part2(input))
+}
diff --git a/src/Utils.kt b/src/Utils.kt
new file mode 100644
index 0000000..acfb72a
--- /dev/null
+++ b/src/Utils.kt
@@ -0,0 +1,13 @@
+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(): String = BigInteger(1, MessageDigest.getInstance("MD5").digest(toByteArray())).toString(16)