Skip to content

Files

Latest commit

 

History

History

2021

2021 Puzzle Summary

Spoiler warnings. I do talk about solutions and techniques I used for the puzzles here, but in a general way.

Day 1 - Sonar Sweep

  • Problem: Compare and sum!
  • Solution: Indexed where clauses did the comparisons. A basic loop grouped the values for part two.

Day 2 - Dive!

  • Problem: Distance iteration.
  • Solution: Basic loop and switch.

Day 3 - Binary Diagnostic

  • Problem: Processing data in columns.
  • 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.

Day 4 - Giant Squid

  • Problem: B.I.N.G.O and giant squid is his name-o.
  • 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.

Day 5 - Hydrothermal Venture

  • Problem: Line intersections.
  • 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.

Day 6 - Lanternfish

  • Problem: Fish population tracking.
  • Solution: Don't try to reinvent a Queue() when you've got one built into the language.

Day 7 - The Treachery of Whales

  • Problem: Fuel consumption.
  • Solution: Didn't need anything fancy. Simple iteration with some sanity checks worked fine. Built a lookup table for the fuel costs in part two.

Day 8 - Seven Segment Search

  • Problem: Determine scrambled codes to work out digits.
  • Solution: Noodled the reduction rules out on some paper, then abused some Linq to generate the answers.

Day 9 - Smoke Basin

  • Problem: Mapping low points.
  • Solution: Part one is a simple neighbor comparison. Using those points, it was a simple matter to build a loop around a Queue to find the basin sizes.

Day 10 - Syntax Scoring

  • Problem: Matching brackets
  • 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.

Day 11 - Dumbo Octopus

  • Problem: Cell automata
  • Solution: Straight forward implementation, no real surprises.

Day 12 - Passage Pathing

  • Problem: Finding all the paths.
  • 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.

Day 13 - Transparent Origami

  • Problem: Folding paper.
  • Solution: The trickiest part of this was keeping the X and Y coordinates straight.

Day 14 - Extended Polymerization

  • Problem: Inserting characters in strings.
  • Solution: Part 1 was easily simulated. Part 2 threw all that away for a memoitization scheme.

Day 15 - Chiton

  • Problem: Pathfinding
  • Solution: Brought forward the A* implemention I have and tweaked the cost function to make each step "cost" the risk value.

Day 16 - Packet Decoder

  • Problem: Nested packet decoding
  • 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.

Day 17 - Trick Shot

  • Problem: Curve prediction.
  • Solution: Straight forward simulation. There's probably some math function that could have done this easier.

Day 18 - Snailfish

  • Problem: Binary tree addition and balancing.
  • 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.

Day 19 - Beacon Scanner

  • Problem: Rotations and translations.
  • 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.

Day 20 - Trench Map

  • Problem: Cellular automata.
  • 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.

Day 21 - Dirac Dice

  • Problem: Round and round the board game.
  • 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.

Day 22 - Reactor Reboot

  • Problem: Intersections of Cuboids
  • 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.

Day 23 - Amphipod

  • Problem: Sort Amphipods back into their homes.
  • 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.

Day 24 - Arithmetic Logic Unit

  • Problem: Incode decompiling.
  • 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.

Day 25 - Sea Cucumber

  • 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.