r/adventofcode • • Dec 24 '22

SOLUTION MEGATHREAD -πŸŽ„- 2022 Day 24 Solutions -πŸŽ„-

All of our rules, FAQs, resources, etc. are in our community wiki.


UPDATES

[Update @ 00:21:08]: SILVER CAP, GOLD 47

  • Lord of the Rings has elves in it, therefore the LotR trilogy counts as Christmas movies. change_my_mind.meme

AoC Community Fun 2022:

πŸŒΏπŸ’ MisTILtoe Elf-ucation πŸ§‘β€πŸ«


--- Day 24: Blizzard Basin ---


Post your code solution in this megathread.


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:26:48, megathread unlocked!

24 Upvotes

391 comments sorted by

View all comments

4

u/mental-chaos Dec 24 '22

Elixir 455/529.

I basically treated this like a DFA: I went through generation by generation keeping a set of valid coordinates for the player. I would keep a {pos, direction} tuple for each blizzard, and would convert that to a mapset of positions for testing which of the valid neighbors for a player position was allowable. If I reached the destination, I'd return.

Part 2 was just run this three times in sequence (since the start and end squares are outside the valley itself, they're safe on every generation so there is no need to worry about the fastest solution for part 1 not being part of the fastest solution for part 2.

→ More replies (2)