Skip to content

massimopavoni/AoC2023-Haskell

Repository files navigation

AoC2023-Haskell

My solutions to the Advent of Code 2023 puzzles

Thoughts

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" 😆

Days

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:

  1. Trebuchet -> megaparsec basics
  2. Cube Conundrum -> more megaparsec, Kleisli arrows, containers
  3. Gear Ratios -> matrix, unordered-containers, more complex megaparsec parser combinators
  4. Scratchcards -> even more megaparsec exploration
  5. If You Give A Seed A Fertilizer -> Functor instances, ranges calculations
  6. Wait For It -> simple closed form algebraic solutions
  7. Camel Cards -> sum types and sorting
  8. Haunted Wasteland -> synchronizing cycles LCM
  9. Mirage Maintenance -> number successions
  10. Pipe Maze -> more matrix operations, loop in a "maze" traversal, Pick's theorem, shoelace formula
  11. Cosmic Expansion -> Manhattan distance, vector
  12. Hot Springs -> dynamic programming, memoization, array, bytestring
  13. Point Of Incidence -> visual matrix partial symmetry
  14. Parabolic Reflector Dish -> 2D tilting physics simulation, modular arithmetic
  15. Lens Library -> silly hashes, more containers and bytestring
  16. The Floor Will Be Lava -> BFS, parallel
  17. Clumsy Crucible -> Dijkstra's algorithm, search-algorithms, cost functions
  18. Lavaduct Lagoon -> Pick's theorem and shoelace formula again
  19. Aplenty -> lens attempts, more complex parsing and ranges calculations
  20. Pulse Propagation -> synchronizing cycles LCM again
  21. Step Counter -> BFS again, hmatrix, input analysis, data interpolation, quadratic growth, linear equations systems
  22. Sand Slabs -> graph theory, graph analysis, graphviz
  23. A Long Walk -> longest path problem, types of graphs, graph simplification by dead-end edge pruning
  24. Never Tell Me The Odds -> line-line intersection, linear optimization, constraint programming, boolean satifiability problems, satifiability modulo theories, cross product properties for computational geometry
  25. 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.

About

My solutions to the Advent of Code 2023 puzzles

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published