DEV Community

Cover image for Advent of Code 2024 - Day 18: Ram Run
Grant Riordan
Grant Riordan

Posted on

1

Advent of Code 2024 - Day 18: Ram Run

Day 18: Ram Run

solution here

Todays challenge was another shortest path first exercise, so once again cracked out Dijkstra algorithm from Day 16.

With a few tweaks and adjustments around costings and such as the costings were more straight forward as every movement was the same price.

Part 1

I began by filling in the corrupted locations, which then gives the terrain for finding the best route using Dijkstras algorithm. Returning the lowest amount of steps.

Part 2

Loop over the input and for each additional corruption check if you can reach the exit.

This could be optimised to work in reverse as we know it’s more likely to occur when more corruptions are added than at the beginning (but that would be a big assumption, and may not be the case for all inputs as in Part 1 we only ran the first 1024 bytes out of 3k+.

As always feel free to reach out on Twitter

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay