adventofcode

Happy Advent 2020! Please put answers in the pinned threads or create one if it does not exist yet. | https://github.com/adventofcode-clojurians/adventofcode-clojurians | Join the private leaderboard with code 217019-4a55b8eb
misha 2019-12-14T10:10:24.024500Z

@pastafari print it out, and you'll immediately know what's up

misha 2019-12-14T10:11:05.025200Z

when in doubt – print it out! :opieop:

misha 2019-12-14T10:13:47.025400Z

day 14 "Elapsed time: 2.936473 msecs" "Elapsed time: 84.136665 msecs"

fellshard 2019-12-14T21:42:20.027200Z

Hmm. Got a solution, really want to figure out how to reliably solve it. Probably a binary / other more informed search method to seek the boundary. As it is, I refined it by hand until it was close enough to solve by just injecting fuel.

fellshard 2019-12-14T21:43:11.028100Z

Got to it late due to family time - not sure how I want to visualize this one, either. I saw some neat diagrams in Reddit.

2019-12-14T22:37:29.029300Z

My submission for day 14. I was afraid part 2 would be very computationally slow, but it executes in ~ 30ms :simple_smile: https://gitlab.com/dmarjenburgh/adventofcode/blob/master/src/adventofcode/year_2019.clj#L397-443

misha 2019-12-15T08:57:57.030500Z

I did split stash and spendings too, but then just allowed negatives in spendings. made it noticeably more readable

misha 2019-12-15T09:03:49.030900Z

but something else runs 3 times slower :opieop:

fellshard 2019-12-15T18:55:22.038200Z

Negative spending - you just make incremental passes to sweep through and request more stock for those entries?

misha 2019-12-15T19:06:57.038700Z

not sure what you mean, but if you need to "buy" 7x but recipe is 10x for 10y, your cost map would be {:y +10 :x -3} where :x -3 is a surplus from transaction you will might use in future transactions

👍 1
misha 2019-12-15T19:07:54.039Z

at first I tried to track 2 maps: cost and surplus: {:y 10}, {:x 3}, but merging those after each transaction was a chore and slow

misha 2019-12-15T19:10:07.039300Z

not terribly readable, but line 48 makes it clear(er) https://github.com/akovantsev/adventofcode/blob/master/src/adventofcode/2019/day14.clj#L43-L54

misha 2019-12-15T19:10:17.039600Z

(< n amount) (assoc cost x (- n amount))

fellshard 2019-12-14T23:01:52.029500Z

That bisect functionality is exactly what I need to steal replicate.