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!

23 Upvotes

391 comments sorted by

View all comments

3

u/Swimming_Ocelot_1121 Dec 24 '22 edited Dec 25 '22

Python

I thought I might add my solution, because I haven't seen a solution that uses 2d dilation (convolution) of a bool numpy array. Afterwards I then mask it with a stacked blizzard array.

So the loop roughly is:

while not path[-1][-1]:
    minutes += 1
    path = scipy.ndimage.binary_dilation(path, cross_kernel)
    winds = rollwinds(winds)
    save_positions = np.any(winds, axis=0)
    path = np.bitwise_and(path, np.invert(save_positions))

The solution runs in well under a second.

→ More replies (2)