6
votes
Day 15: Oxygen System
Today's problem description: https://adventofcode.com/2019/day/15
Join the Tildes private leaderboard! You can do that on this page, by entering join code 730956-de85ce0c.
Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python with any of the "short names" listed in this page of supported languages):
<details>
<summary>Part 1</summary>
```python
Your code here.
```
</details>
This was an interesting one, I kept having little issues where my robot would get lost and start plotting to the wrong places while mapping.
Day 15
I spent a bunch of time on setting up mapping display and interactivity which ended up being kind of waste, if rather entertaining.
Wandering around manually, I quickly noticed that the map was all single-tile corridors, so a naive "keep the wall on the left" approach would probably get me somewhere interesting eventually. It wasn't too difficult to write a function to have the robot check a direction and then return back to its original position if it actually succeeded in moving forward.
Sticking to the left wall, my robot quickly found the goal, but its path was apparently sub-optimal, so I needed to explore more. I set the robot to just keep exploring in the same manner, building up a map as it goes. In my case I just had it stop after 3k steps, but I'm sure a more elegant solution is possible.
Once you have the map, the actual solutions are quite straightforward graph problems: A* from the start to the station, then flood-fill from the station and count the steps.
Day 15 Crystal
I am catching up! If I can do two a day from now through Christmas I will only finish a day late heh. Anyway, I was lazy and did this in a very slow and clunky way, but it worked and I didn't have to think too hard about it.
Intputer.py
RepairBot.py
Oxygen.py