Advent of Code 2020
January 10, 2021
Completed!
I finished the Advent of Code for 2020, and this time pushed myself past the holiday indulgences to actually complete all 50 challenges!
I pushed myself to use Elixir for everything this year, and barring a few small instances where being able to mutate a value would have saved me a lot of headaches (specifically this evil creation) it was a pretty awesome experience. Aside from the usual 2D grid geometry problems, there were a lot of new things in there and I discovered some nice things on the way.
Here's some unsorted notes and discoveries I made during the whole process.
Notes
- Elixir's pattern matching is really nice for interpreting VM instructions
- Just pattern match the op code, extract the params and do the operation!
- Conway's game of life can be extended to higher dimensions (hypercubes of life haha)
- Simply keep track of the live nodes, and create a function to find the neighbors of each node
- The number of times a certain neighbor is duplicated in the output is the number of live neighbors it has
- By changing the neighbor function to work on 2D, 3D or 4D coordinates, you get the behavior of the system in a higher dimension!
- Day 20 was by far the most involving
- To even get to validate the test cases took a lot of effort
- A lot of image convolution
- Elixir / Erlang map keys are ordered by default up to 32 entries
- Regex lookahead is a thing
- I've somehow never needed to find overlapping matches in a pattern space before
- A deep sense of fear sets within me..
Checkout the code in my GitHub Repo