Advent of Code 2016

I completed all fifty stars for Advent of Code 2016 in Go. Solutions live in the bandarji/aoc repository under go/adventofcode/. Each day below summarizes the puzzle and the approach in my code.

Advent of Code 2016 Complete

Five Favorite Days

Here, I shall reveal the days I had the most fun coding. These do not represent the easiest nor the toughest, just which ones I enjoyed for some reason or another.

One: Signals and Noise (Day 6)

Given strings of equal length, assemble one string comprised of the most frequent character from each index. For part two, use the least frequent. Easy to code a solution, though I wonder if a more elegant method exists over the way I processed the rows of strings into a slice of string “stripes”.

> make run YEAR=2016 DAY=6
Year=2016 Day=06 Part 1: mlncjgdg (673.583µs)
Year=2016 Day=06 Part 2: bipjaytb (527.5µs)

Two: Internet Protocol Version 7 (Day 7)

This puzzle provided a collection of IPv7 addresses. Thank goodness we do not use these! To solve, this came down to examining the string for patterns within and outside square brackets. I feared that part two might have another character considered as brackets, but it almost seemed easier to solve (most likely because of the fresh work arriving at working code for part one).

> make run YEAR=2016 DAY=7
Year=2016 Day=07 Part 1: 105 (14.317125ms)
Year=2016 Day=07 Part 2: 258 (11.37775ms)

Three: Leonardo’s Monorail (Day 12)

At only 47 lines of code, this ends up one of the shortest solutions I have ever written to solve an entire day’s puzzles. I enjoy writing these assembly instruction processors.

> make run YEAR=2016 DAY=12
Year=2016 Day=12 Part 1: 318009 (50.240917ms)
Year=2016 Day=12 Part 2: 9227663 (1.070393458s)

Four: Safe Cracking (Day 23)

Another assembly instruction processor. The long solve time for part two informs me that an optimized solution exists. Perhaps a loop predictor can shave processing time. I shall revisit this one in the future.

> make run YEAR=2016 DAY=23
Year=2016 Day=23 Part 1: 12516 (4.011083ms)
Year=2016 Day=23 Part 2: 479009076 (2m48.048298583s)

Five: Air Duct Spelunking (Day 24)

My breadth-first search approach might not have ended up the best way to solve this puzzle, looking at the solve times. Twenty-tree minutes!!! Regardless, I had a lot of fun with this puzzle.

> make run YEAR=2016 DAY=24
Year=2016 Day=24 Part 1: 462 (36.7143725s)
Year=2016 Day=24 Part 2: 676 (23m14.0485975s)

Most Hated

Okay, one day took me way too many hours to figure out. I ended up rewriting the code for this day over and over. Day Eleven’s “Radioisotope Thermoelectric Generators” looks and feels much like the familiar programming for getting feed, a chicken and a fox across a river. For some reason, the coding ended up different enough and the logic much tougher. Part two did not add complexity, just more elements to track, making the computer perform many, many extra cycles. I think one of the challenges I ran into come down to properly encoding a string for memoization, but I have looked over this code so much that I have lost track.

> make run YEAR=2016 DAY=11
Year=2016 Day=11 Part 1: 31 (3.697371916s)
Year=2016 Day=11 Part 2: 55 (5m1.774147917s)