https://kotlinlang.org logo
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
  • j

    Joris PZ

    12/17/2019, 3:48 PM
    My day 17: https://github.com/jorispz/aoc-2019/blob/master/src/commonMain/kotlin/day17/p17.kt I went low-tech and did part 2 by hand using Excel, given the small world map it seemed a lot quicker than creating an algorithm
    m
    k
    • 3
    • 21
  • r

    rocketraman

    12/17/2019, 5:45 PM
    Hey guys, I'm back on day 7, part 1 (yeah, a bit behind :-)) -- I was happy because (seemingly) my existing computer from day 5 was sufficient for day 7 without any changes. However, upon testing, I see my code works on the specific phases given, but as far as I can tell those are not the max thruster values of those programs. Can someone confirm for me what the output of program
    3,15,3,16,1002,16,10,16,1,16,15,15,4,15,99,0,0
    should be with phases
    4,3,2,2,0
    ? It should be less than
    43210
    according to the text, but I get
    43220
    .
    m
    • 2
    • 28
  • j

    Jakub Gwóźdź

    12/18/2019, 8:51 AM
    My solution, based on coroutines and Flow: https://github.com/jakubgwozdz/AdventOfCode/blob/master/src/advent2019/day17/Route.kt most difficult part was algorithmically finding the routine and functions A, B, C. I did it by testing all possible subpaths and adding some optimizations: • function A is 1 up to 5 first elements of path • function C is 1 up to 5 last elements of path • function B is any 0 up to 5 elements of path • main routine is 10 calls long, starts with A, ends with C, and has 0 to 8 calls of A,B,C inside And then I perform a loop that takes every combination of A,B,C and main and tests if it results in previously found scaffolding route I wonder if I could do it less brutey forcey
    • 1
    • 1
  • r

    rocketraman

    12/18/2019, 6:49 PM
    For day 7, part 2, I used coroutines with `Channel`s to send I/O around the amps. I have one coroutine for each amp, as well as the system I/O (initial inputs, amp E output). However, I get indeterministic results if I run the coroutines multi-threaded -- using a single-threaded dispatcher works fine. Did anyone else have a similar approach and run into this?
    k
    j
    • 3
    • 34
  • k

    Kroppeb

    12/19/2019, 5:30 AM
    I lost 50 points due to my compiler freezing twice
    • 1
    • 2
  • t

    todd.ginsberg

    12/19/2019, 9:50 PM
    I'm back from traveling and managed to do Day 19. I'll catch up on 15 through 18 over the weekend. 🙂
    👍 3
    • 1
    • 3
  • r

    Rostyslav

    12/20/2019, 9:56 AM
    I had a mistake in my input for Day20. One portal has 4 points instead of two. To earn the star I had to find a mistake and correct the input manually 😞
    k
    • 2
    • 4
  • t

    todd.ginsberg

    12/21/2019, 12:06 AM
    Wow, I don't get Day 20, Part 2 at all.
    r
    • 2
    • 3
  • t

    todd.ginsberg

    12/22/2019, 12:48 AM
    GRRRR. I walked my dogs and came up with the answer - my input.txt was corrupted! Redownloading and running again worked fine. No idea how that happened.
    😞 2
    k
    • 2
    • 2
  • t

    todd.ginsberg

    12/22/2019, 5:52 PM
    Went back and finished Day 17 instead of 22P2. I just went manual (drew my maze, figured out the path, programmed it by hand). I guess there's probably a way to generalize that, but I'm probably not going to bother considering that one was 5 days ago and nobody is going to read that post anyway. 😄
    r
    • 2
    • 4
  • r

    Rostyslav

    12/23/2019, 7:02 PM
    Finally managed to finish Day 22. Had to learn some new material to do it myself. It was quite an interesting experience. Some spoilers in the thread. https://github.com/Rtchaik/AoC2019/blob/master/src/advent2019/day22/solution22.kt
    t
    • 2
    • 4
  • r

    Rostyslav

    12/24/2019, 12:10 PM
    Day24: https://github.com/Rtchaik/AoC2019/blob/master/src/advent2019/day24/solution24.kt
    t
    • 2
    • 1
  • r

    Rostyslav

    12/25/2019, 12:21 PM
    Day 25 was done partly manually and the last stage automated: https://github.com/Rtchaik/AoC2019/blob/master/src/advent2019/day25/solution25.kt
    t
    • 2
    • 1
  • j

    Jakub Gwóźdź

    01/07/2020, 5:41 PM
    Ok I might be a week or something late to the party, but I wanted to see if JVM solutions can be easily ported to the browser, and lo and behold, they can. Almost copy-paste 🙂 here, enjoy my awesome frontend skills at https://jakubgwozdz.github.io/JSTry104/cryostasis.html (last puzzle partial solution)
    e
    • 2
    • 2
  • t

    todd.ginsberg

    11/01/2020, 5:33 PM
    I said last year at the end that I wasn't going to blog about my solutions again, but I probably will. Last year I was in temporary housing, so my work setup was essentially a TV tray and a crappy chair in the side of my bedroom, so not ideal. And I had some travel so I fell behind. But this year, I'm finally in a house with a dedicated office (in Raleigh, NC, if anybody is close!) and since covid is here, I won't be going anywhere. So I guess why not? I probably won't change much about how I do it - solve the puzzle, optimize for clarity instead of speed, attempt to explain it all with a blog post, ideally day-of.
    👏 4
    👍 2
    m
    m
    • 3
    • 13
  • t

    todd.ginsberg

    11/01/2020, 5:35 PM
    I can't include the text of the problem in my posts any more, I got called out on Twitter by one of the AoC people (which I thought was rude, they could have emailed me and I would have removed them all). I think that's a bit of a bummer, it makes the solution harder to connect to the problem, but I can't do much about that as I don't want to get into a "fair use" argument with them.
    😞 2
    n
    • 2
    • 2
  • j

    Joris PZ

    11/21/2020, 7:25 PM
    I promised myself I would branch out this year and use AoC to learn some other language, but doing it in Kotlin is just too attractive.... So once more I will be attempting to do AoC 2020 in Kotlin common code, and run my solution on the JVM, in Node, and using a native executable on Windows. For no particular reason I'll be using GraalVM for running the JVM part, and will probably see what happens when I run the JS version in Graal as well.
    ➕ 1
    🎉 2
    m
    t
    • 3
    • 4
  • p

    poohbar

    11/23/2020, 10:09 PM
    Does anyone remember how the two different ordering algorithms work in the leaderboard? Or at least how they worked last year 🤔
    j
    t
    • 3
    • 5
  • m

    marstran

    11/30/2020, 4:59 PM
    2^-1 🔥 (We will never reach the release if we continue like this)
    😱 2
    d
    • 2
    • 1
  • j

    Joris PZ

    12/01/2020, 9:25 AM
    My day 1 solution in common code: https://github.com/jorispz/aoc-2020/blob/master/src/commonMain/kotlin/day1/p01.kt I had a lot of frustrating infrastructure issues. My existing IntelliJ run configuration somehow got corrupted, which took me ages to figure out. Then, my native build didn't work, exited quietly without throwing any kind of error or stacktrace, just an exit code which hinted at a null pointer. The solution isn't particularly nice or clean, but it's been enough for today 🙂 Below the timing measurements for JVM (OpenJDK11), NodeJS and native. (The times were drastically improved by some preprocessing on the input which you can find on line 9 in the source)
    💪 2
    👍 1
    m
    r
    +3
    • 6
    • 18
  • t

    todd.ginsberg

    12/01/2020, 1:21 PM
    That was a fun start. I'll post mine later, but it's a nested set of
    mapNotNull
    and
    first()
    calls. 🙂
    👍 1
    a
    • 2
    • 1
  • t

    todd.ginsberg

    12/01/2020, 9:20 PM
    [Thread] Links to my solution and post.
    🎉 2
    a
    e
    • 3
    • 20
  • b

    bjonnh

    12/02/2020, 3:33 AM
    My 1ms solution (plus a dumb and slightly less dumb): https://github.com/bjonnh/advent_of_code/blob/master/src/main/kotlin/y2020/day01/main.kt
    e
    • 2
    • 18
  • b

    bjonnh

    12/02/2020, 4:42 AM
    ok I can wait
    😂 2
    a
    • 2
    • 6
  • a

    adamratzman

    12/02/2020, 5:06 AM
    319th on part 1, 177th on part 2. code in thread:
    • 1
    • 2
  • a

    adamratzman

    12/02/2020, 5:11 AM
    how’d you solve it?
    b
    w
    +3
    • 6
    • 10
  • j

    Joris PZ

    12/02/2020, 7:57 AM
    My day 2 solution here, timings per platform below. Nothing particularly fancy, quite pleased with how extension functions help with readability.
    | JVM (OpenJDK 11) | 9.1 ±  14.7  | `71, 16, 11,  7,  7,  6,  5,  5,  5,  8,  4,  5,  2,  3,  3,  4,  2,  2,  4,  4` |
    | Node JS          | 17.4 ± 18.6  | `90, 43, 25, 20, 12, 10,  8,  8,  9,  8,  9,  8,  8,  8, 19, 11, 11, 11,  9, 11` |
    | Native           | 39.1 ±  7.5  | `36, 36, 37, 34, 34, 36, 34, 45, 41, 68, 34, 42, 36, 35, 42, 34, 38, 35, 41, 34` |
    👍 1
    t
    b
    • 3
    • 3
  • j

    Jakub Gwóźdź

    12/02/2020, 9:49 AM
    aaand - back to day1 - I believe I managed to do O(n^2) in part2 and kind-of O(n) in part1 (kind-of, because it requires input to be sorted, so O(nlogn) effectively). testable version on https://jakubgwozdz.github.io/advent-of-code-2020/day01/ - I wonder if I missed any edge case
    j
    t
    +2
    • 5
    • 8
  • m

    mickeelm

    12/02/2020, 10:26 AM
    Does anyone know of a resource for generating/getting very large valid puzzle inputs?
    j
    t
    • 3
    • 8
  • b

    bjonnh

    12/02/2020, 3:02 PM
    I try to avoid regexps due to their lower performance
    e
    • 2
    • 3
Powered by Linen
Title
b

bjonnh

12/02/2020, 3:02 PM
I try to avoid regexps due to their lower performance
e

ephemient

12/02/2020, 6:45 PM
compared to what? depends on the regex and engine, but they can definitely be faster than code you would reasonably write by hand
backtracking can kill performance, you just have to know how about it
b

bjonnh

12/02/2020, 7:12 PM
mmm next one I'll do with regexp then, just to put them more in my workflow
View count: 2