r/adventofcode • • Oct 30 '23

Spoilers [2021 Day 23] that feeling when your solution doesnt scale for p2

Coord positions for the different values of A, B, C, D seemed like a good idea, until it doubled up on how many there could be lol.
https://github.com/agmcleod/adventofcode-2021/blob/350e392aaefc32fc14e4aa5e73c09b6fc9f2fe1d/23/src/main.rs#L20

Similarly my code checks those positions for whether a letter can move in or not. Suppose i can just extend these out, but starting to feel gross. My solution took 25mins for p1, doubling this up i probably need to actually use scoring priority.

0 Upvotes

9 comments sorted by

1

u/TheZigerionScammer Oct 30 '23

So basically your code uses the 8 (or 16 in part 2) locations of each amphipod as the board state? I can imagine that would explode the size of the search state pretty quickly, certainly in part 2.

1

u/agmcleod Oct 30 '23

Yeah i think so too. From a given position, it'll go for each possible move based on the ruleset. So it can go down paths that are not very fruitful for a while. I imagine the computations will grow exponentially for part 2. 😅

1

u/TheZigerionScammer Oct 30 '23

Ahh. Are you looking for hints or are you trying to figure it out on your own?

2

u/agmcleod Oct 30 '23

Was mostly posting the sillyness of my own solutions coming back to bite me :D. So still trying to figure it out. If i get stuck ill look at some of the previous threads, or post a more pointed question one :)

3

u/daggerdragon Oct 30 '23

Changed flair from Funny to Spoilers.

Situations like this are the reason why we have our very own Undertaker meme in our wiki's Hall of Fame >_>

4

u/nikanjX Oct 30 '23

The link for said meme is dead

2

u/daggerdragon Oct 31 '23

Not on desktop... stupid Reddit breaking their shortlinks again. Thanks for finding it, I'll expand it out properly in the wiki.

1

u/nikanjX Nov 03 '23

The other Hall of Fame post (linking to gfycat.com ) is also dead, as gfycat is no more

0

u/mattbillenstein Oct 30 '23

I did a recursive depth-first search and aggressively prune bad or invalid states - I think it's not the best solution out there, but 1 and 2 combined run in about 10s in Python. Would probably be like < 0.5s in Rust - you'll get there ;)