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
  • u

    user

    12/02/2021, 5:00 AM
    Advent of Code 2021 day 2 🧵
    d
    p
    +12
    • 14
    • 35
  • p

    pavi2410

    12/02/2021, 5:17 AM
    Why does IJ says the result is always zero? The variables get updated in the code that's hidden
    d
    k
    p
    • 4
    • 5
  • u

    user

    12/03/2021, 5:00 AM
    Advent of Code 2021 day 3 🧵
    d
    p
    +19
    • 21
    • 45
  • c

    cak

    12/03/2021, 3:05 PM
    If one of y'all makes a Kotlin private leaderboard, please send me the code. I'd love to join to virtually meet others in the community and help keep up the momentum! :kotlin: 🎄 ❤️
    👍 1
    e
    m
    m
    • 4
    • 4
  • m

    Michael Grigoryan

    12/03/2021, 7:18 PM
    Can someone help me with today's second puzzle? I'm having some trouble with comprehending it :blob-smile:
    e
    m
    t
    • 4
    • 14
  • b

    Big Chungus

    12/03/2021, 7:44 PM
    If anyone is still looking for a painless AOC2021 workspace to dive straight to coding, look no further - https://github.com/mpetuska/aoc-2021-kmp Comes packed with testing framework, test inputs, execution time measurements and validation. Oh and it runs on ALL kotlin targets, which allows you to compare how your solution performs under different runtimes (GH actions included if you don't have 3 laptops) :D All you need to do is implement a single method for each day with your solution.
    e
    p
    +2
    • 5
    • 21
  • u

    user

    12/04/2021, 5:00 AM
    Advent of Code 2021 day 4 🧵
    d
    m
    +13
    • 15
    • 36
  • k

    kqr

    12/04/2021, 6:16 PM
    isn't there a way to continuously ask sequence for any number of items?
    e
    • 2
    • 6
  • u

    user

    12/05/2021, 5:00 AM
    Advent of Code 2021 day 5 🧵
    d
    s
    +14
    • 16
    • 34
  • m

    Marcin Wisniowski

    12/05/2021, 10:19 AM
    I made a visualization for Day 5: https://streamable.com/weice8
    🙌 6
    a
    d
    t
    • 4
    • 5
  • u

    user

    12/06/2021, 5:00 AM
    Advent of Code 2021 day 6 🧵
    d
    m
    +18
    • 20
    • 45
  • u

    user

    12/07/2021, 5:00 AM
    Advent of Code 2021 day 7 🧵
    d
    s
    +12
    • 14
    • 37
  • u

    user

    12/08/2021, 5:00 AM
    Advent of Code 2021 day 8 🧵
    d
    d
    +13
    • 15
    • 41
  • t

    todd.ginsberg

    12/08/2021, 5:23 PM
    At least we’ll have this race once Formula 1 ends this weekend…
    e
    d
    • 3
    • 13
  • m

    Michael de Kaste

    12/08/2021, 5:49 PM
    btw, this happened during my coding today, and I have no idea why the compiler trips:
    i
    d
    • 3
    • 4
  • e

    ephemient

    12/08/2021, 8:33 PM
    kotlinx.benchmark doesn't work with Kotlin/Native (at least not in recent versions of Gradle & Kotlin) nor JS IR, but the difference between JS (legacy) and JVM results is unbelievable. https://ephemient.github.io/aoc2021/jmh-visualizer/index.html
    • 1
    • 1
  • u

    user

    12/09/2021, 5:00 AM
    Advent of Code 2021 day 9 🧵
    m
    d
    +13
    • 15
    • 46
  • n

    Nir

    12/09/2021, 4:21 PM
    This worked fine. Coming from python, my natural instinct to extend this for two years was, I created a folder called 2020, and a folder called 2021, and had the same stuff in each one. The problem is that kotlin packages aren't intrinsically hierarchical. So if I have a file called day1.kt in both the 2020 and 2021 folder, and they both have package day1 at the top, and both define same function names, it starts complaining about duplicate function definitions
    m
    e
    • 3
    • 13
  • m

    Michael Böiers

    12/09/2021, 5:06 PM
    Quick question: Do you think it’s cheating to have a large number of utility functions prepared? I think that in a way it is. Difficult to say! To me AoC is about finding a good solution from scratch using only what comes with the language, but then again templates are probably fine. Not sure where to draw a line …
    p
    s
    +3
    • 6
    • 13
  • n

    Nir

    12/09/2021, 5:46 PM
    Is there a particular reason Kotlin doesn't have integer exponentiation? Seems a bit odd to me tbh
    e
    • 2
    • 7
  • u

    user

    12/10/2021, 5:00 AM
    Advent of Code 2021 day 10 🧵
    d
    s
    +14
    • 16
    • 27
  • m

    Michael de Kaste

    12/10/2021, 12:25 PM
    I am once again asking for a standardized SealedMap implementation like an EnumMap
    p
    e
    • 3
    • 4
  • n

    Nir

    12/10/2021, 4:11 PM
    Anyone else been caught a couple times by Kotlin's 32 bit integer default? smh
    ➕ 8
    p
    e
    • 3
    • 35
  • u

    user

    12/11/2021, 5:00 AM
    Advent of Code 2021 day 11 🧵
    d
    m
    +13
    • 15
    • 34
  • u

    user

    12/12/2021, 5:00 AM
    Advent of Code 2021 day 12 🧵
    m
    j
    +10
    • 12
    • 30
  • u

    user

    12/13/2021, 5:00 AM
    Advent of Code 2021 day 13 🧵
    d
    j
    +14
    • 16
    • 46
  • m

    Michael de Kaste

    12/13/2021, 1:10 PM
    with the printing of the ouput taking in mind; what monospaced font do you guys use (if any)? 🙂
    p
    j
    +4
    • 7
    • 13
  • g

    gnu

    12/14/2021, 1:11 AM
    Since many of you seem to like 100%-functional, all-in-one-solutions: I have really a hard time understanding those 20-to-30-line-functions with deeply nested lambdas without the help of an IDE. I have to keep track of a whole stack of receivers and inferred data types ... most of the time, I get lost half way through it. I'm a TDD-developer, leaning more to the clean-coders-approach with very small, easy-to-understand functions and well defined in- and out-data-types. After creating a test first (which is a template for this contest), I write a really crappy imperative solution to get the correct answer fast. After that, during the refactoring phase, I do all the extractions and renamings, finally converting everything to functional. What do you think, is this a bit over-engineered for these kind of contests?
    :nice: 1
    e
    j
    +4
    • 7
    • 14
  • u

    user

    12/14/2021, 5:00 AM
    Advent of Code 2021 day 14 🧵
    d
    m
    +11
    • 13
    • 57
  • n

    Nir

    12/14/2021, 7:44 PM
    1. A simple histogram of elements given a list of stuff. I end up doing this usually
    some_stuff.groupBy { it }.mapValues { it.value.size }
    Which works but feels a bit silly from a couple of angles
    e
    m
    l
    • 4
    • 5
Powered by Linen
Title
n

Nir

12/14/2021, 7:44 PM
1. A simple histogram of elements given a list of stuff. I end up doing this usually
some_stuff.groupBy { it }.mapValues { it.value.size }
Which works but feels a bit silly from a couple of angles
e

ephemient

12/14/2021, 7:45 PM
this was discussed in today's thread:
some_stuff.groupingBy { it }.eachCount()
🙏 1
n

Nir

12/14/2021, 7:45 PM
yeah, I'm aware of groupingBy as well, will be a bit faster I guess
I'll probably add my own extension function then
m

Michael Böiers

12/14/2021, 8:03 PM
I usually find it silly when I have to write
{ it }
. In this case a small wrapper function (e.g.
grouped()
) would be nice. It’s just much more readable in particular when in a nested lambda (e.g. flatMap)
👍 2
l

Luke

12/14/2021, 8:54 PM
I like the syntax with Arrow's
identity
fonction:
groupingBy(::identity)
View count: 6