Advent of Code 2024 - Day 11

Greetings, Erlang adventurers! :wave: Ukrainian Erlanger is here! :metal: Today, we delve into the mysterious world of Plutonian Pebbles. :rock: As we observe the spacetime-manipulating stones and decipher their strange transformations, it’s time to showcase the power of Erlang for recursive and rule-based problems. :rocket:

The task: Simulate the evolution of the stones over 25 blinks, following their specific transformation rules. The challenge grows with the stones splitting and multiplying - this is a perfect opportunity to use Erlang’s robust pattern-matching and recursion!

:bulb: Tips for tackling Day 11:

  • Start by parsing the initial stone numbers into a list for easy manipulation.
  • Use recursion to handle each “blink,” applying the transformation rules systematically.
  • Be mindful of performance - efficiently handling the exponential growth of stones is key to solving the problem for larger inputs.

:sparkles: Motivation for today:
Great things are done one step (or one blink) at a time. Let’s evolve, transform, and Beam together!

Share your approaches, insights, and solutions below. Whether you’re puzzling over splitting stones or tackling the multiplication rule, this is your space to collaborate and learn.

Happy coding, and may your stones always align perfectly! :christmas_tree::computer:

1 Like

I tried the explicit recursive version without any state. It worked for part 1 but would have taken ages to finish for part 2. I asked my colleagues for a hint and ended with advent_of_code_2024/src/solution_day_11_2024.erl at main · chiroptical/advent_of_code_2024 · GitHub (the hint was basically a data structure). It was so obvious after the hint.

I feel like we had one of these last year and I made the same mistake.

2 Likes

The recursive one with no storage optimizations advent_of_code_2024/src/solution_day_11_2024_old.erl at main · chiroptical/advent_of_code_2024 · GitHub (if you’re curious)

2 Likes

Great to see you tackling it! The recursive approach is definitely elegant. Leveraging the right data structure can make all the difference, and it’s always nice to have colleagues to brainstorm with. Learning from past challenges is what makes AoC so rewarding - awesome work adapting and pushing forward! :rocket::christmas_tree: