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/11/2018, 5:32 PM
    What kind of machine are you running this on? Because my implementation is essentially the same as yours but won't go below ca 40 ms
    j
    • 2
    • 27
  • t

    todd.ginsberg

    12/11/2018, 5:56 PM
    Grrrr.... lower right hand corner != upper left hand corner. Aka "why are all my answers off by 2?!"
    l
    j
    j
    • 4
    • 5
  • a

    andyb

    12/12/2018, 11:38 AM
    I don't think that you need to go beyond about 200 iterations as the resulting pattern settles to a Steady State even through it drifts rightward 1 character per iteration. After this all this does is add a score of 1 per alive plant per iteration & so you can shortcut the calculation for 50,000,000,000
    l
    • 2
    • 1
  • t

    todd.ginsberg

    12/12/2018, 6:25 PM
    I got to use
    window
    , so that's always a good time. 🙂
    👍 1
    a
    • 2
    • 2
  • j

    joelpedraza

    12/12/2018, 7:03 PM
    If you want to punish yourself: Heres an oscillator whose cycle starts at 2 and ends at 4, and glides off to positive infinity.
    initial state: ##.##..#
    
    ..... => .
    ....# => .
    ...#. => .
    ...## => .
    ..#.. => #
    ..#.# => .
    ..##. => .
    ..### => .
    .#... => .
    .#..# => .
    .#.#. => .
    .#.## => .
    .##.. => .
    .##.# => .
    .###. => .
    .#### => .
    #.... => #
    #...# => .
    #..#. => .
    #..## => .
    #.#.. => .
    #.#.# => .
    #.##. => .
    #.### => .
    ##... => .
    ##..# => .
    ##.#. => .
    ##.## => #
    ###.. => .
    ###.# => .
    ####. => .
    ##### => .
    k
    • 2
    • 1
  • k

    karelpeeters

    12/12/2018, 10:49 PM
    I tried to optimize my code in preparation from part two but of course as it turns out that still wasn't fast enough.
    j
    • 2
    • 4
  • k

    keturn

    12/13/2018, 8:11 AM
    Okay, I have rendering for Minecart Madness part 1, but I think I'm going to sleep before I do their movements.
    👍 5
    v
    f
    • 3
    • 3
  • k

    karelpeeters

    12/13/2018, 12:30 PM
    Nothing special today, it was easier than expected when I first saw the input 😒imple_smile:
    j
    • 2
    • 9
  • l

    littlelightcz

    12/13/2018, 2:19 PM
    I got only Part B wrong, but I have no idea why. Code from @andyb works fine with different result. So maybe I didn't understand the question correctly, although for their example input for part B my result is correct.
    Day_13.kt
    j
    • 2
    • 3
  • j

    Joris PZ

    12/13/2018, 3:44 PM
    My day 13 is here: https://github.com/jorispz/aoc-2018/blob/master/src/commonMain/kotlin/P13.kt No interesting constructs that others haven't posted earlier, though I am quite pleased with
    private val turns = sequenceOf(Turn.LEFT, Turn.STRAIGHT, Turn.RIGHT).infinite().iterator()
    Today's timings also nothing surprising (first/best of 25 in ms): JVM
    182/13
    , JS
    206/75
    , native
    1048/995
    👍 1
    l
    • 2
    • 4
  • j

    joelpedraza

    12/13/2018, 6:37 PM
    Instant regret
    k
    t
    +2
    • 5
    • 10
  • a

    andyb

    12/14/2018, 6:55 AM
    Day 14: Yet another win for Kotlin Sequences 🙂 Initial solution here: https://gitlab.com/abowes/adventofcode2018/blob/master/src/main/kotlin/jfactory/day14/ChocolateCharts.kt
    r
    k
    • 3
    • 3
  • k

    karelpeeters

    12/15/2018, 9:29 AM
    You can't have the stoppingpoint as an
    Int
    , what if it starts with
    '0'
    like one of the testcases?
    t
    • 2
    • 6
  • g

    Gerard Klijs

    12/15/2018, 10:03 PM
    I'm kind of stuck on the second part, all the examples work, but apparently my answer is wrong 😞
    n
    k
    • 3
    • 15
  • j

    Joris PZ

    12/15/2018, 11:51 PM
    Giving up for today, still working on part 1. My code handles the examples correctly, but is terribly slow on the real input, a combination of doing too much work with way too much memory. More tomorrow, though I might do day 16 first
    a
    k
    • 3
    • 8
  • t

    todd.ginsberg

    12/16/2018, 3:53 AM
    I feel the same. I write all these up, but since I disable comments on my blog who the heck knows if anybody even sees it.
    j
    k
    • 3
    • 2
  • t

    todd.ginsberg

    12/16/2018, 4:03 AM
    So there's that. Maybe I don't understand how reading order works?
    k
    • 2
    • 2
  • m

    Marcin Wisniowski

    12/16/2018, 4:04 AM
    Oh why Slack, a platform for professionals has no syntax highlighting, and Discord, a platform for gamers, has highlighting for all languages. 😕
    k
    • 2
    • 4
  • m

    Marcin Wisniowski

    12/16/2018, 7:22 AM
    @Rostyslav Isn't it a little confusing that you assigned numbers to opcodes in your executing function but they are not the real opcode numbers? I couldn't figure out how did you know the opcode numbers straight away to write that function. 😄
    r
    • 2
    • 1
  • k

    keturn

    12/16/2018, 8:18 AM
    I might give up on day 15 unless we get more test cases that are blessed as correct by Saint Nicholas himself. Right now I'm trying to debug based on comments on reddit, but some of them directly contradict each other 😖
    g
    j
    • 3
    • 2
  • k

    karelpeeters

    12/16/2018, 11:09 AM
    You people need to learn how to write your lists of functions more compactly 😉
    a
    l
    • 3
    • 3
  • p

    Pavlo Liapota

    12/16/2018, 12:22 PM
    Found a nice usage of
    generateSequence
    for second part of Day 15:
    return generateSequence(4) { it + 1 }
        .map { elfAttack -> fight(inputs, elfAttack) }
        .first { result -> result.beings.none { it.kind == BeingKind.ELF && !it.alive } }
        .score
    👍 1
    m
    • 2
    • 2
  • k

    karelpeeters

    12/16/2018, 12:37 PM
    I often want function that generates an infinite list of incrementing numbers, but I keep forgetting about
    generateSequence
    !
    o
    • 2
    • 15
  • k

    karelpeeters

    12/16/2018, 7:26 PM
    Heh that reminds me: what does the program we interpreted today actually do?
    j
    m
    r
    • 4
    • 10
  • t

    todd.ginsberg

    12/16/2018, 9:47 PM
    Part 1 is fine. part 2 gives wrong answer. I've had no time to work on this between moving, chores and errands associated with it, and debilitating headaches I get sometimes. I found all of the operations that seem to be singletons by removing ids from contention, but it yields the wrong answer. So either I'm doing that wrong and have the wrong instructions or I'm executing one wrong. Blah.
    j
    • 2
    • 3
  • t

    todd.ginsberg

    12/17/2018, 12:40 AM
    I'm pretty sure my Day 15 isn't working because of a) My pathfinding algorithm is the wrong choice (A*) and I should have done a more straight forward DFS, b) Constant headaches keeping me from focusing on details, c) Lack of time. Going to write up D16 and then try again later. I feel like I'm close, finding paths better is possibly it.
    a
    • 2
    • 2
  • m

    Marcin Wisniowski

    12/17/2018, 10:27 AM
    Finished and generated a video: https://streamable.com/i29ew
    👍 1
    🚰 1
    p
    l
    • 3
    • 2
  • e

    Edgars

    12/17/2018, 5:54 PM
    I think it's time to call it quits with AoC for now. At least on a "do it every day" basis. Puzzles have gotten too hard to 'casually' solve them, plus I'm way behind my Master's coursework (which I might bail on anyway). It was fun while the drive lasted, I'll definitely tackle the problems when I have free time again. 🙂
    k
    t
    • 3
    • 2
  • k

    karelpeeters

    12/17/2018, 7:41 PM
    Maybe there's a better way, I hate the literal code duplication there.
    p
    j
    • 3
    • 4
  • j

    Joris PZ

    12/17/2018, 8:07 PM
    Your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should...
    enum class Soil {
        `+`, `.`, `#`, `~`, `|`, `x`
    }
    k
    • 2
    • 3
Powered by Linen
Title
j

Joris PZ

12/17/2018, 8:07 PM
Your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should...
enum class Soil {
    `+`, `.`, `#`, `~`, `|`, `x`
}
Well, joke's on me - IDEA accepts it fine, but the compiler panics 🙂
😔 1
k

karelpeeters

12/19/2018, 10:54 PM
Why do you need
x
?
j

Joris PZ

12/20/2018, 5:41 AM
Oh, that meant undefined, not sure if I actually used it but I didn't want to return null or throw on index out of bounds
View count: 9