r/adventofcode • u/daggerdragon • Dec 15 '22
SOLUTION MEGATHREAD -π- 2022 Day 15 Solutions -π-
THE USUAL REMINDERS
All of our rules, FAQs, resources, etc. are in our community wiki.
A request from Eric: A note on responding to [Help] threads
Signal boost: Reminder 2: unofficial AoC Survey 2022 (closes Dec 22nd)
πΏπ MisTILtoe Elf-ucation π§βπ« is OPEN for submissions!
--- Day 15: Beacon Exclusion Zone ---
Post your code solution in this megathread.
Read the full posting rules in our community wiki before you post!
Include what language(s) your solution uses
Format code blocks using the four-spaces Markdown syntax!
Quick link to Topaz's
pasteif you need it for longer code blocks. What is Topaz'spastetool?
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:27:14, megathread unlocked!
47
Upvotes
12
u/jonathan_paulson Dec 15 '22
python3, 143/72. Video. Code.
Tough problem! I spent a long time debugging on part 1, but still managed to sneak back onto the leaderboard for part 2.
I used the fact that if there is a unique position for the last beacon, it must be at distance d+1 from one of the sensors (where "d" is the distance to the closest beacon). This gives a "linear" number of positions to check - about 85 million for my input. Still a lot, but much better than 16 trillion.
The reason is that otherwise the last beacon would not be unique; some adjacent square would also be valid.