Advent of Code 2022 Day 2 | Kotlin

preview_player
Показать описание

For a warm up, we’ve gathered some helpful Advent of Code resources:

We invite you to join our special Kotlin leaderboards! To sign up, go to the Leaderboard section of your Advent of Code profile and use one of the codes below:
Leaderboard 1: 236080-b0695394
Leaderboard 2: 2343137-1def15d6
Leaderboard 3: 2076885-8e47e445
Leaderboard 4: 2553918-9ee8ee21
Leaderboard 5: 2649199-9168a817
Leaderboard 6: 2716400-8dd8cad2
Leaderboard 7: 2789857-33778dc1

Please join just one leaderboard. Thanks!
Рекомендации по теме
Комментарии
Автор

Quick&dirty destructuring a String is actually quite simple:

val (opponent, _, you) = line.toString()

Because String.toList() gives you a List<Char> which supports destructuring directly. ;-) Of course it has an overhead of creating a list, but here that is not a problem!

ZordidMuc
Автор

Not sure I agree with using mathematical tricks to encode score logic, suppose one of those score values change now the entire * 3 hack falls apart. It's also less obvious.

gitboy
Автор

I think I wouldn't enjoy working on a project with Maton Braun 😅

samwelotieno