Giving up for today, still working on part 1. My c...
# advent-of-code
j
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
Same here, although my almost working solution is not that slow even on full input.
k
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
@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
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
Yes, and the same call a few lines above on line 103
k
So doesn't he only count the current round if there are still enemies alive?
j
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!