Caching and Pattern matching - Day 12 - Advent of Code

In this episode, we walk through solving day 12 of Advent of Code 2023, called "Hot Springs". The challenge involves parsing records of hot springs, some of which are damaged (#) or operational (.), along with checksums indicating groups of damaged springs.

First, we set up some test cases and write a parse method to process the input. Then we implement a count method using recursion and pattern matching to count all valid arrangements of springs that match the checksums. Key cases include:
- Encountering a "?" which represents variable springs
- Incrementing "group size" when we hit pound signs to track damaged groups
- Checking that group sizes match checksums when we reach periods
- Caching results to speed things up

For part 2, we expand the strings by duplicating parts and joining them to make the problem more complex. More optimizations like collapsing multiple dots and returning early based on string lengths are added.

In the end, we arrive at a working solution that passes the test cases and puzzle input!

Advent of Code: https://adventofcode.com/
My Solutions: https://gist.github.com/cjavdev/d15a2a4ffed6c840c2fb28a093e9f927/
Playlist https://www.youtube.com/playlist?list=PLS6F722u-R6KYlGyUv65EFpGKl2Esmurr

#adventofcode #ruby