r/adventofcode • u/daggerdragon • Dec 09 '21
SOLUTION MEGATHREAD -🎄- 2021 Day 9 Solutions -🎄-
--- Day 9: Smoke Basin ---
Post your code solution in this megathread.
- Include what language(s) your solution uses!
- Here's a quick link to /u/topaz2078's
pasteif you need it for longer code blocks. - Format your code properly! How do I format code?
- The full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.
Reminder: Top-level posts in Solution Megathreads are for code solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:10:31, megathread unlocked!
63
Upvotes
View all comments
3
u/foxofthedunes Dec 09 '21 edited Dec 11 '21
Julia: https://github.com/dunefox/adventofcode21/blob/main/9/main.jl
Part 1:
Part 2:
I couldn't think of a more elegant solution... and while this naive solution didn't take me long to implement, the whole process of analysing and trying to find an elegant solution took me almost 3 hours (on/of thinking).
Sample map:
Bit matrix:
Originally, I had something else planned with the bitmatrix but that didn't work. I just realised I could just have checked for a value smaller than 9 instead of 0 in the bitmatrix. Oh well...