Advent of Code 2023 - Day 22

preview_player
Показать описание
I placed 89th on part 1; 68th on part 2; now 5th overall.

Pretty straightforward brute force.

I had a nasty bug on part 1 that took me a while to find; a block can't fall if there's a block below it, but a vertical block shouldn't stop *itself* from falling. I also had some issues resetting the state between blocks on part 2.

Рекомендации по теме
Комментарии
Автор

I let it run over night, but my implementation for part 1 took 3 hours 😬. After rewriting it, it only took 2 minutes, but that was stil pretty slow. I think your method of using SEEN to effectively treat every other brick as part of one giant blob helps a lot with the speed! Unfortunately, I think that's sort of what led to the bug in part 1, too.

gsainsbury
Автор

I sorted the blocks in descending z directions and used an intersect function on x and y coordinate to find the highest brick below the current brick.
Then I can immediately move the current brick to one space above it, no matter the fall distance.

harisimer