Advent of Code 2024 - Day 14

Greetings, Erlang adventurers! :wave: Ukrainian Erlanger is here! :metal: Today, we find ourselves navigating the high-tech security of Easter Bunny Headquarters, where robots patrol in predictable straight lines. Our challenge: Predict their movements and calculate the safety factor after 100 seconds to help The Historian safely reach the bathroom. :restroom::robot:

The task: Simulate the motion of robots in a 2D space with wrap-around boundaries, count the robots in each quadrant after 100 seconds, and calculate the safety factor by multiplying the robot counts from all four quadrants.

:bulb: Tips for solving Day 14:

  1. Parse the Input: Convert positions and velocities into an easily iterable structure, such as tuples or maps.
  2. Simulate Movement: For each robot, calculate its new position after 100 seconds, accounting for teleportation (wrap-around edges).
  3. Divide Quadrants: Determine which quadrant each robot is in after simulation.
  4. Calculate Safety Factor: Count the robots in each quadrant and multiply the totals.

:sparkles: Challenge Motivation:
Even in a sea of robots, precision and planning pave the way. Let’s decode the chaos and Beam together!

Share your strategies, challenges, and solutions below. Whether you’re debugging teleportation logic or counting quadrant totals, this is the place to learn and collaborate.

Happy coding, and may your robots move in predictable paths! :christmas_tree::computer:

1 Like

I originally solved this puzzle in Elixir.

Inspired by solutions in the elixir forum and reddit, here is my Erlang solution with different approaches for both parts.

The runtime is about one second.

1 Like

Your Erlang solution is impressive! :muscle: I like how you combined concise list comprehensions.

The runtime of about one second is great for a problem with this level of complexity. Thank you for sharing your approach - it’s both insightful and inspiring for others tackling this challenge. Great work! :rocket:

1 Like