diff options
author | tchojnacki <tomaszchojnacki2001@gmail.com> | 2021-12-03 14:04:21 +0100 |
---|---|---|
committer | tchojnacki <tomaszchojnacki2001@gmail.com> | 2021-12-03 14:04:21 +0100 |
commit | e422b972d872b05ea6c8f7f62680ac483ba107a4 (patch) | |
tree | c4931601e3f69405e13c3ea390fbfb236bcdc459 /src/Day01.kt | |
parent | 69dc8bd159e304f84f44c2f631470e4deb523f0a (diff) | |
download | gleam_aoc2020-e422b972d872b05ea6c8f7f62680ac483ba107a4.tar.gz gleam_aoc2020-e422b972d872b05ea6c8f7f62680ac483ba107a4.zip |
Minor refactoring of all solutions
Diffstat (limited to 'src/Day01.kt')
-rw-r--r-- | src/Day01.kt | 10 |
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)) } |