My solutions to the Advent of Code 2023 puzzles
The solutions are run all together in the Main module,
compiled down to a single optimized executable.
The answers are obviously specific to the inputs, which is why I made it so that anyone
can build and run the project with their own inputs (although I tested the program only on Linux).
This was my very first ever Advent of Code
and I had a lot of conflicting feelings and opinions about it.
In the end, I'm glad I tried and made it to the end, despite taking a lot of time
and the puzzle solutions not being all original (had some help from Reddit here
and here) or optimized enough to run in less than a second.
The best part was surely learning a lot of new stuff about Haskell and all the different topics that inspired the puzzles, as well as how to approach problems with a "heavily functional mindset" 😆
Instead of going through each day and writing any sort of write-up, I would like to list some of the most interesting and useful concepts I reviewed and studied for the problems (if you're intrigued, you can always explore the repository and check out the code in detail).
Very "dry" summary of days:
- Trebuchet -> megaparsec basics
- Cube Conundrum -> more megaparsec, Kleisli arrows, containers
- Gear Ratios -> matrix, unordered-containers, more complex megaparsec parser combinators
- Scratchcards -> even more megaparsec exploration
- If You Give A Seed A Fertilizer -> Functor instances, ranges calculations
- Wait For It -> simple closed form algebraic solutions
- Camel Cards -> sum types and sorting
- Haunted Wasteland -> synchronizing cycles LCM
- Mirage Maintenance -> number successions
- Pipe Maze -> more matrix operations, loop in a "maze" traversal, Pick's theorem, shoelace formula
- Cosmic Expansion -> Manhattan distance, vector
- Hot Springs -> dynamic programming, memoization, array, bytestring
- Point Of Incidence -> visual matrix partial symmetry
- Parabolic Reflector Dish -> 2D tilting physics simulation, modular arithmetic
- Lens Library -> silly hashes, more containers and bytestring
- The Floor Will Be Lava -> BFS, parallel
- Clumsy Crucible -> Dijkstra's algorithm, search-algorithms, cost functions
- Lavaduct Lagoon -> Pick's theorem and shoelace formula again
- Aplenty -> lens attempts, more complex parsing and ranges calculations
- Pulse Propagation -> synchronizing cycles LCM again
- Step Counter -> BFS again, hmatrix, input analysis, data interpolation, quadratic growth, linear equations systems
- Sand Slabs -> graph theory, graph analysis, graphviz
- A Long Walk -> longest path problem, types of graphs, graph simplification by dead-end edge pruning
- Never Tell Me The Odds -> line-line intersection, linear optimization, constraint programming, boolean satifiability problems, satifiability modulo theories, cross product properties for computational geometry
- Snowverload -> graph components, graph connectivity, graph partitioning, min-cut problem, Karger-Stein algorithm, random, spectral partitioning and spectral bisection, spectral graph theory, Laplacian matrix, eigendecomposition, eigenvalues and eigenvectors, Fiedler vector
Some additional things I learned during AoC2023 are: Stack project management, Haskell program profiling, multiple language extensions and pragmas usage, some more commonly used and useful libraries, point-free style (slightly obfuscating code), better understanding of Functor-Applicative-Monad, file handling and resources embedding.