Advent of Code 2017

I completed all fifty stars for Advent of Code 2017 in Go. Solutions live in the bandarji/aoc repository under go/adventofcode/. This blog entry summarizes my favorite and least favorite puzzles from this year, along with my code approaches.

Five Favorite Days

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

One: High-Entropy Passphrases (Day 4)

An easy puzzle to solve. Basically, construct a map of the individual strings on a line. If the string already exists as a key, then the line is an invalid passphrase. Part two added a check for anagrams.

> make run YEAR=2017 DAY=4
Year=2017 Day=04 Part 1: 466 (410.5µs)
Year=2017 Day=04 Part 2: 251 (662.125µs)

Two: I Heard You Like Registers (Day 8)

Run through some pseudo assembly instructions, then, depending on the puzzle part, return the highest register value after processing or at any point during processing.

> make run YEAR=2017 DAY=8
Year=2017 Day=08 Part 1: 4902 (623.542µs)
Year=2017 Day=08 Part 2: 7037 (364.416µs)

Three: Duet (Day 18)

I suppose I enjoy the assembly processing problems. Part two had me run two “programs” at the same time.

> make run YEAR=2017 DAY=18
Year=2017 Day=18 Part 1: 1187 (758.334µs)
Year=2017 Day=18 Part 2: 5969 (14.021292ms)

Four: A Series of Tubes (Day 19)

Trace a pipe, constructing a string of waypoints encountered along the path. For part two, count the number of steps it takes to traverse the entire path. Very easy puzzle, but still fun to code.

> make run YEAR=2017 DAY=19
Year=2017 Day=19 Part 1: KGPTMEJVS (699.958µs)
Year=2017 Day=19 Part 2: 16328 (185.75µs)

Five: Sporifica Virus (Day 22)

This one took me longer to code than it should have. Looking back, I should have used enum instead of simple integers for the various position states.

> make run YEAR=2017 DAY=22
Year=2017 Day=22 Part 1: 5433 (1.368666ms)
Year=2017 Day=22 Part 2: 2512599 (389.277125ms)

Most Hated

Day 24: Electromagnetic Moat

Given a list of string values with numbers separated by a slash, determine the longest “bridge” formed with values from either side of the slashes chain together because they match. I’m certain that my conditionals are prime for a rewrite, but I got the code to work. By that point, I was happy to get this year over the finish line.

> make run YEAR=2017 DAY=24
Year=2017 Day=24 Part 1: 1868 (2.382918875s)
Year=2017 Day=24 Part 2: 1841 (2.389316458s)