
This year, I got asked a couple of times about the libraries I use for the Advent of Code in Elixir. So I decided to put together a small article to take you through my toolbox.
Graphs
For graph problems such as the ones listed below:
- Digital Plumber
- Universal Orbit Map
- Passage Pathing
- Handy Haversacks
- Knights of the Dinner Table
- Recursive Circus
- The Sum of Its Parts
- All in a Single Night
- A Regular Map
I tend to use libgraph which makes the experience of working with the :digraph Erlang module a delight.
In most cases you can get away with creating the graph and using the a_star/4 function or the dijkstra/3 function to calculate the shortest path.
There has been a couple of cases where those algorithms haven’t been usable out of the box but still having some helper functions (such as out_neighbours/2) makes it a breeze for you to be able to rollout your own traversal.
Another great use of this library is the fact that it has a efficient PriorityQueue implementation which has come in handy more than once.