5
votes
Day 18: Boiling Boulder
Today's problem description: https://adventofcode.com/2022/day/18
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>
My loony bun is fine Benny Lava
Data
My lava is a hash with key cube co-ordinates. I allowed myself mutable state for the limits of the lava. We live in dangerous times!Part 1
I've come to realise I SUCK at geometry problems.
I spent ages confused about what cubes that are "not connected" could mean when the first tiny example had CONNECTED cubes. Once I figured out what was actually required, it turned out to be pretty simple. You just count the faces of each cube that doesn't touch another. (Touching me... TOUCHING YOU..!!!!)
Part 2
Had no idea what to do at first. I considered writing a 3d convex hull :(. Did I ever tell you how much I SUCK at geometry? I realised though, I could just start outside the lava and mark everything with higher co-ordinates that is non-cube and not yet marked. Then for all points NOT connected to a cube (now I know what that means!) and not marked external, count how many faces do touch another cube. Subtract that from the count of all faces (from part 1). Horribly inefficient but glad to get a finish. I'll speed it up later.
Edit: Oh dear. I left in a
set-union
inmark-external
from an experiment I abandoned. There's no need repeatedly merge sets that differ by 1 element! It really slow things down. smhNow poop on them Oliver!
Rust
I'm way behind. I need to get back to day 16/17 now.
Rust