So what if you are like me and you want to build an executable that can pick and choose which problem’s code to run?
What if you are like me again and are tired of the workflow consisting of:
- Exporting a solver function from the problem’s module
- Importing the solver function in the main module
- Adding the solver function to a map with the correct key
Part A is a simple 2SUM. We use
Vector to speed up computation due to Part B.
AoC presents us with another computer challenge. We conjure up some data types representing the console state as well as
Our first goal here is to simplify the input. We conjure up the
replace function and make some replacements to our
text. We also define a data type for bags holding other bags and how to parse the cleaned up text.
This is a fantastic use case for
lens. We define a passport to be a list of fields and a field to be a key
value pair. The parser is also rather simple.