aboutsummaryrefslogtreecommitdiff
path: root/src/Day01.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/Day01.kt')
-rw-r--r--src/Day01.kt10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/Day01.kt b/src/Day01.kt
index 7503c69..6d45527 100644
--- a/src/Day01.kt
+++ b/src/Day01.kt
@@ -1,24 +1,22 @@
fun main() {
- fun part1(input: List<String>): Int =
+ fun part1(input: List<Int>): Int =
input
- .map { it.toInt() }
.zipWithNext()
.count { it.second > it.first }
- fun part2(input: List<String>): Int =
+ fun part2(input: List<Int>): Int =
input
.asSequence()
- .map { it.toInt() }
.windowed(3)
.map { it.sum() }
.zipWithNext()
.count { it.second > it.first }
- val testInput = readInput("Day01_test")
+ val testInput = readInputAsNumbers("Day01_test")
check(part1(testInput) == 7)
check(part2(testInput) == 5)
- val input = readInput("Day01")
+ val input = readInputAsNumbers("Day01")
println(part1(input))
println(part2(input))
}