You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Solution: I got clever here and used bit manipulation for both parts. I converted everything to integers at the top. 2019 Day 24 provided getBit() and setBit() functions, which I used to sum and set bits set in the various columns for part one. Part two used List<int> and some light predicate functions to filter things down.
Solution: More bitmasking with 2019 Day 24's helper functions. I turned the 2D card into a 1D list and bit flipped an int to track which numbers had been called on the card. A precomputed bitmask was then applied to check for a win condition. Part two took me a little bit to figure out how to stop processing cards that had already won, but it was obvious in hindsight.
Solution: Walked the lines with basic loops. The diagonal took a bit to noodle out, and had an early error where it would skip the final point on the line. Oops.
Solution: Part one was easy once I got out of my own way and stopped trying to do it recursivly. For part two it really helped to read the problem description.
Solution: No best path optimization here, we need to find all of them. I didn't complicate this for myself and left everything as strings. Second part needed a little noodling, but the addition of a flag the first time backtracking happens solved the problem.
Solution: One misread on the process and I spent way too long debugging a version where I incorrectly flushed the buffer after gathering the packets. Sorting that out and everything came together nicely.
Solution: So much recursion. Once I realized I had an easy way to return the tree to a string, for the add function, I created new Node() with concatinated strings. For part two, some foreach trickery gave me all the combos of strings to add up.
Solution: Heavy iteration, and some surprisingly light matrix calls. The biggest bottleneck is the the Intersect call to determine overlaps. Removing this would require some restructuring of the solution.
Solution: Cellular automata is becoming a straightforward problem. The trick was to figure out how to handle the infinate boarder that changed state each step. A logic test on the border solved that.
Solution: Part one was easy to simulate. Part two required some noodling on how to reduce the search space. The key is realizing that while dice rolls will multiply, only the results and how many times those results happen matter.
Solution: Part one could be brute forced, but I skipped doing that and focused instead on merging and splitting cubeoids. I had a nearly working solution that broke a pair of cuboids into 27 bits. Looking at the solution thread told me I was on the right track and this post showed me where I was messing up.
Solution: I thought making A* work might be too much for this, ... so this finished with something that looks a lot like A*. Culling duplicate states was the biggest speedup, with the next ones being precomputing the move distanaces and storing if a critter is in its final position.
Solution: Fourteen functions that feed into each other. Working them backward had some promising early results. The key hint is that the functions are paired in a way where when the output of one is the input of the next, it'll return the key value to it's origional state. The real trick was getting my output to a place where it was useful.
Problem: Track the migration habits of Sea Cucumbers
Solution: This was a straight forward simulation. I initially did it with flipping boards, but realized that it'd be easier with one board and careful moves.