this post was submitted on 19 Nov 2023
1 points (60.0% liked)

Advent of Code

283 readers
1 users here now

Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

https://adventofcode.com

founded 1 year ago
MODERATORS
1
submitted 11 months ago* (last edited 11 months ago) by [email protected] to c/[email protected]
 

As a warmup for this year's Advent of Code, I'm re-reading and posting my solutions to last year's challenges. You can read, run and edit today's solution by following the post link.

Today was a sudden increase in difficulty (for me anyway). We had to find the best route for opening a system of valves to maximise the total flow through the network. Part two repeated the exercise, but with the addition of a friendly elephant to help with the work.

I was able to simplify the network enough to solve part 1 in a reasonable time, but had to hack my solution for part 2 terribly to get it under a second. Reading some other solutions, I missed out on some key approaches including pre-calculating minimum paths between all pairs of valves (e.g. using the Floyd–Warshall algorithm), aggressive caching of intermediate states, and separating out my movements from the elephant's movements.

Go and read @[email protected]'s Clojure solution for a much more thoughtful approach :smile:

top 1 comments
sorted by: hot top controversial new old
[–] [email protected] 2 points 11 months ago

Thanks for the shout out!

I remember this being a really tricky one to tweak. It's always around 18-20 when things really ramp up. I still haven't braved: https://adventofcode.com/2018/day/15

This is a great set of data plots to see all the tricky problems 😁 https://www.maurits.vdschee.nl/scatterplot/