https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
advent-of-code
  • n

    Nir

    12/14/2021, 7:50 PM
    2. Keeping counts of things as mutable state.
    MutableMap<T, Long>
    is okay-ish for this, but incrementing feels very awkward
    myCounts[something] = myCounts.getOrDefault(something, 0) + numberFound
    I've generally found that updating state in maps can be a bit annoying so I do have a general helper function (which I think would be worth having in stdlib tbh)
    fun <K, V> MutableMap<K, V>.update(k: K, transform: (V?) -> V) = set(k, transform(get(k)))
    So it becomes
    myCounts.update(k) { (it ?: 0) + numberFound
    But still, end up repeating quite a bit. If there isn't a better way then I may just have a dedicated Counter (a la python) and possibly deal with both things with one stone
    🙏 1
    e
    l
    7 replies · 3 participants
  • u

    user

    12/15/2021, 5:00 AM
    Advent of Code 2021 day 15 🧵
    d
    e
    +10
    77 replies · 12 participants
  • i

    ilya.gorbunov

    12/15/2021, 7:20 AM
    Tip: if you're stuck on part 2 (like me) because your code gives the right result for the example input, but wrong for your own input, check that your path finding algorithm of part 1 produces the right result for the following input (in thread)
    t
    2 replies · 2 participants
  • u

    user

    12/16/2021, 5:00 AM
    Advent of Code 2021 day 16 🧵
    :kotlin-intensifies-purple: 2
    d
    m
    +11
    80 replies · 13 participants
  • m

    Michael de Kaste

    12/16/2021, 6:29 AM
    without looking at the docs, guess what this does:
    val packetVersion = stringbuilder.removeRange(0..2).toLong(2)
    I guessed wrong this morning 😉
    e
    e
    +1
    11 replies · 4 participants
  • e

    Endre Deak

    12/16/2021, 4:56 PM
    is there a nice alternative for the following?
    // s is my input representation and once a portion is processed, I remove that portion
    
    val sub = mutableListOf<Packet>()
    
    while(!s.isEmpty()) {
       sub.add(processPacket(s))
    }
    
    return sub
    e
    e
    +2
    10 replies · 5 participants
  • u

    user

    12/17/2021, 5:00 AM
    Advent of Code 2021 day 17 🧵
    d
    i
    +14
    52 replies · 16 participants
  • u

    user

    12/18/2021, 5:00 AM
    Advent of Code 2021 day 18 🧵
    e
    j
    +11
    50 replies · 13 participants
  • k

    Kiet

    12/18/2021, 10:17 AM
    so I have a list that I want to fold but I want the initial element to be the FIRST element of the list. Does kotlin have a specific method for this?
    1 reply · 1 participant
  • k

    Kiet

    12/19/2021, 4:28 AM
    Is there a kotlin method for doing this?
    var explosionResult = result.explode(0)
    while (explosionResult.explosionOcurred) {
        explosionResult = result.explode(0)
    }
    e
    2 replies · 2 participants
  • u

    user

    12/19/2021, 5:00 AM
    Advent of Code 2021 day 19 🧵
    k
    e
    +12
    55 replies · 14 participants
  • m

    Michael de Kaste

    12/19/2021, 12:42 PM
    any idiomatic way to do this?
    functionThatReturnsNullable() ?: doOnNull() followed by continue
    e
    e
    7 replies · 3 participants
  • n

    Nir

    12/19/2021, 6:23 PM
    my understanding was that you would pick a property for something that is essentially cheap/cached/"read off" and a function for something that actually requires computation. So size as a property makes sense; any collection in Kotlin should cheaply know its size. But if it cheaply knows its size, it must cheaply know whether its empty? If size has to be cheaply available, then even having
    isEmpty
    as an extension property with
    size == 0
    seems fine...
    e
    j
    6 replies · 3 participants
  • u

    user

    12/20/2021, 5:00 AM
    Advent of Code 2021 day 20 🧵
    i
    d
    +10
    24 replies · 12 participants
  • d

    David Whittaker

    12/20/2021, 6:09 PM
    Anyone else take scratch notes while puzzle-solving? I have a mini whiteboard I can use on my desk.
    e
    3 replies · 2 participants
  • d

    David Whittaker

    12/21/2021, 2:13 AM
    Any votes on tonight's difficulty from 1 being day 1-level to 10 being 👿?
    4️⃣ 1
    5️⃣ 1
    3️⃣ 2
    e
    m
    3 replies · 3 participants
  • u

    user

    12/21/2021, 5:00 AM
    Advent of Code 2021 day 21 🧵
    d
    e
    +10
    80 replies · 12 participants
  • u

    user

    12/22/2021, 5:00 AM
    Advent of Code 2021 day 22 🧵
    j
    j
    +8
    35 replies · 10 participants
  • k

    Kiet

    12/22/2021, 6:25 AM
    Is the description the same for everyone else?
    e
    2 replies · 2 participants
  • u

    user

    12/23/2021, 5:00 AM
    Advent of Code 2021 day 23 🧵
    d
    e
    +3
    21 replies · 5 participants
  • u

    user

    12/24/2021, 5:00 AM
    Advent of Code 2021 day 24 🧵
    d
    e
    +10
    49 replies · 12 participants
  • u

    user

    12/25/2021, 5:00 AM
    Advent of Code 2021 day 25 🎄
    d
    p
    +6
    8 replies · 8 participants
  • t

    todd.ginsberg

    01/07/2022, 1:05 PM
    Did anybody here end up winning any prizes from JetBrains for participating in Advent of Code? If so, what did you win? 🙂
    😢 1
    🇳🇴 17
    d
    k
    +1
    6 replies · 4 participants
  • k

    Ksenia Shneyveys

    01/27/2022, 5:04 PM
    Dear all! Thank you so much for your participation in AoC 2021, for your posts, discussions, for sharing your solutions and helping others. It was great! With this blogpost and video we’d like to announce and congratulate the winners 🥁 https://blog.jetbrains.com/kotlin/2022/01/advent-of-code-2021-in-kotlin-winners/
    ♥️ 6
    🎉 13
    m
    p
    +9
    17 replies · 12 participants
  • m

    Mikael Alfredsson

    02/06/2022, 8:56 AM
    How can I remove duplicated consecutive values in a list by a specific field? [{a,1},{b,1},{c,2},{d,2},{e,1}] -> [{a,1}{c,2},{e,1}]
    e
    f
    +1
    6 replies · 4 participants
  • d

    David Whittaker

    03/01/2022, 7:03 AM
    Did y'all already know about this? https://blog.jetbrains.com/kotlin/2022/02/kotlin-heroes-episode-9/
    k
    p
    2 replies · 3 participants
  • p

    Paul Woitaschek

    03/15/2022, 4:26 PM
    Advent Advent! :kotlinnew: 💕 Thanks for the fantastic time and the shirts
    😍 5
    :kotlin-flag: 2
    🎉 14
    😄 1
    j
    1 reply · 2 participants
  • j

    Jakub Gwóźdź

    10/30/2022, 5:11 AM
    D-0x20, folks. Exciting!
    p
    d
    +4
    8 replies · 7 participants
  • k

    Kroppeb

    11/11/2022, 5:40 PM
    Are there plans to have another contest this year?
    e
    k
    +5
    14 replies · 8 participants
  • j

    Jakub Gwóźdź

    11/23/2022, 4:45 AM
    D-2^3, :kotlin-intensifies-purple: , almost there, almost there 🙂 :kotlin-intensifies-purple:
Powered by Linen
Title
j

Jakub Gwóźdź

11/23/2022, 4:45 AM
D-2^3, :kotlin-intensifies-purple: , almost there, almost there 🙂 :kotlin-intensifies-purple:
View count: 3