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

andyb

12/15/2018, 11:58 PM
Same here, although my almost working solution is not that slow even on full input.
k

karelpeeters

12/16/2018, 12:07 AM
Then I'll be interested to see yours once it's finished! I really can't think of an elegant way to make it faster.
a

andyb

12/17/2018, 4:25 PM
@karelpeeters Day15 - Part1 solution is here which runs in <1sec. Still getting incorrect answer for Part 2 & no time to resolve. https://gitlab.com/abowes/adventofcode2018/blob/master/src/main/kotlin/jfactory/day15/BeverageBandits.kt
👍 1
j

Joris PZ

12/17/2018, 6:59 PM
Nice clean code! Two things I noticed that might help with the second part. First, it seems to me your stop condition for part 1 looks if there are still enemies alive of the first sprite in the list. I think this only works if the first sprite is alive? Second, there is some weird logic about how to count full rounds, which I don't think you implemented. Essentially, if a army wins halfway through a round, that round shouldn't count towards the total.
j

Joris PZ

12/17/2018, 7:30 PM
Yes, and the same call a few lines above on line 103
k

karelpeeters

12/17/2018, 7:31 PM
So doesn't he only count the current round if there are still enemies alive?
j

Joris PZ

12/17/2018, 7:33 PM
You're absolutely right. And, my other point is also invalid, because I now see on line 112 that dead sprites get removed. So, wrong on both counts, I was!
3 Views