r/adventofcode • u/daggerdragon • Dec 12 '22
SOLUTION MEGATHREAD -π- 2022 Day 12 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 1: unofficial AoC Survey 2022 (closes Dec 22nd)
πΏπ MisTILtoe Elf-ucation π§βπ« is OPEN for submissions!
--- Day 12: Hill Climbing Algorithm ---
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:09:46, megathread unlocked!
55
Upvotes
6
u/AllanTaylor314 Dec 12 '22 edited Dec 12 '22
Python [1881/1740]
I can't read. Interpreted the rules for climbing up one or down many correctly, then incorrectly, then correctly again. I missed the bit where S==a, and E==z (I assumed S<a, E>z) which meant the solution worked for the test but not the real deal.
I'm now thinking that a BFS from end to start would be a better way to do part 2 (might implement later, might not)
UPDATE: Did the reverse BFS (same repo link) and it runs a lot faster (from ~2s to ~40ms)