aboutsummaryrefslogtreecommitdiff
path: root/2021-kotlin/src/Day01.kt
diff options
context:
space:
mode:
Diffstat (limited to '2021-kotlin/src/Day01.kt')
-rw-r--r--2021-kotlin/src/Day01.kt24
1 files changed, 0 insertions, 24 deletions
diff --git a/2021-kotlin/src/Day01.kt b/2021-kotlin/src/Day01.kt
deleted file mode 100644
index 4ac1ef7..0000000
--- a/2021-kotlin/src/Day01.kt
+++ /dev/null
@@ -1,24 +0,0 @@
-object Day01 {
- fun part1(input: List<Int>) =
- input
- .zipWithNext()
- .count { it.second > it.first }
-
- fun part2(input: List<Int>) =
- input
- .asSequence()
- .windowed(3)
- .map { it.sum() }
- .zipWithNext()
- .count { it.second > it.first }
-}
-
-fun main() {
- val testInput = readInputAsNumbers("Day01_test")
- check(Day01.part1(testInput) == 7)
- check(Day01.part2(testInput) == 5)
-
- val input = readInputAsNumbers("Day01")
- println(Day01.part1(input))
- println(Day01.part2(input))
-}