We're running out of air, but don't worry: our old pal the IntCode Robot is back to help us out.
Day 15 - The Problem
More bad news! We're running out of air, and we have no idea about the shape of our ship. Luckily, our care package contains an IntCode program that can run an Oxygen System Repair Robot.
We need to find an efficient path to the Oxygen System location in Part 1. Fire up those IntCodes and get searching our mazelike module.
Part 2 needs us to see how long we have to wait until the area is safe to go into again. We may need a better map...
Ongoing Meta
Dev.to List of Leaderboards
-
120635-5c140b9a
- provided by Linda Thompson
If you were part of Ryan Palo's leaderboard last year, you're still a member of that!
If you want me to add your leaderboard code to this page, reply to one of these posts and/or send me a DM containing your code and any theming or notes you’d like me to add. (You can find your private leaderboard code on your "Private Leaderboard" page.)
I'll edit in any leaderboards that people want to post, along with any description for the kinds of people you want to have on it. (My leaderboard is being used as my office's leaderboard.) And if I get something wrong, please call me out or message me and I’ll fix it ASAP.
There's no limit to the number of leaderboards you can join, so there's no problem belonging to a "Beginner" and a language specific one if you want.
Neat Statistics
I'm planning on adding some statistics, but other than "what languages did we see yesterday" does anyone have any ideas?
Languages Seen On Day 13
Under construction
Top comments (4)
IntCodes on odd days as usual. Will we have to use them on Christmas too? 🤔
At first was considering getting the map out of the input itself, but it's hidden well enough so I thought it was easier to give it a try anyway.
So, the approach. Instead of the suggested way of backtracking with the drone, I decided to keep a "frontier" of tiles next to unexplored ones, and expand it at every iteration until the leak is reached (for part one) or the frontier is empty (for part two).
Therefor "frontier" consists in an object mapping coordinates with the "state" of the machine (which has to be copied). The only optimization I made here to my IntCode machine was using a
Uint16Array
instead of a normal array, but it wasn't really necessary.To the code (in JavaScript):
The
evolveFrontier
function takes three arguments:The first part is now rather easy:
The values
tankMap
andtankFrontier
will be needed for the second part:Find today's text, my input the my complete solution at my repo.
let to the party. Swift here --->
Since it was Sunday I took the remote control metaphor to heart, added a server socket, modified my C IntCode machine so the socket performed the input and output, then went off to write the exploring code in another language to run in a separate process. I literally have to open two shells to run the solution.
Part 1 was an obvious depth-first search so I thought I'll do the search code in Haskell. Time was a bit broken up today but I got a bit bogged down in backtracking behaviour that wasn't quite tracking the correct position of the repair droid. Got there in the end however, and using depth-first meant the shortest route to the oxygen system fell out of the recorded path used for backtracking.
Part 2 is a classic "flood fill" algorithm. My space was encoded as a map of positions to contents, so an efficient implementation wasn't going to fall out naturally. Thankfully the space was small enough that it runs quickly:
Really ugly kotlin solution.
I did this without state, and this caused me some wacky problems. I'll reply with a cleaner version later.