Happy Advent-of-Code season! :santa::gift: For any...
# advent-of-code
v
Happy Advent-of-Code season! 🎅🎁 For anyone solving in Kotlin, there’s a fun new twist this year: Golfcoder, an open-source advent-of-code community leaderboard focused on code size. No midnight race, no time pressure, just creative Kotlin and tiny solutions. Try it out and share your Kotlin magic: https://golfcoder.org (PS: Golfcoder counts code tokens not code characters, so no need for "obfuscation")
👍 2
m
Yes, I did that last year. Just finished for day 1, I'm currently in the top spot for Kotlin. Not going to beat the Ruby solution 😉 https://golfcoder.org/2025/day/1
😮 1
Just tried a runningFold version for day 1 part 1, but it's still more code than my current solution:
Copy code
fun main() = println(generateSequence(::readLine).runningFold(50) { acc, line ->
    acc + line.substring(1).toInt() * if (line[0] == 'R') 1 else -1
}.count { it % 100 == 0 })
mind blown 1
v
runningFold ... uh nice, didn't know about that stdlib function. Nice trick 🙂
m
^ Yes, but it's a few tokens longer than the shortest version I could come up with:
Copy code
var dial = 50

fun main() = println(generateSequence(::readLine).count {
    dial += it.replace("R", "").replace("L", "-").toInt()
    dial % 100 == 0
})
mind blown 1