Day 12: Hot Springs

AdventuRust - AoC 2023

This is Day 12 of Advent of Code 2023! If you would like to solve the problems before looking at the solution, you can find them here.

In part 1 of Day 12, we have wildcards representing either an operational hot spring (denoted by a .) or a damaged hot spring (denoted by a #). We've been given the pattern in which damaged hot springs are clustered, and we need to figure out the number of potential combinations that are allowed using the wildcards. I ran into some weird - maybe interesting - issues with the pow() function that can return any type of numeric value, but it only takes a u32 as an exponent (see SO post here). Another thing I learnt was to replace a character in a string at a given index using the replace_range() function - I guess a cleaner way to write a single position replacement instead of pos..pos+1 could be pos..=pos. The logic itself is pretty simple - I used rayon again to parallelize the processing and calculate the sum of possible combinations for all lines. Click here to jump to the part 2 "discussion".

For part 2 of Day 12, it would have been useful to have come up with a smarter solution for part 1 because you can't really brute force part 2. Unfortunately I did not have the bandwidth or the patience to refactor the code to make part 2 run, so this part is left as an exercise for the reader.

That's all folks! If you made it this far, enjoy some AI art generated by u/dimpopo using the prompt for this puzzle.