Sean McLemon | Advent of Code

Home | Czech | Blog | GitHub | Advent Of Code | Notes

My Advent Of Code 2019 solutions. See also 2021, 2020, 2018, 2017, 2016 and 2015.


2019-12-25 - Cryostasis

Day 25 puzzle input is an IntCode program (mine is here) which presents a little text adventure. Part 1 involves making your way through this text adventure until you get to a point where you are given a password. This doesn't sound too tough but you essentially need to go through the adventure, pick up a bunch of objects which weigh certain value and find which combination of them let you pass through a given security gate. I solved this by creating an interactive wrapper around my IntCode interpreter and discovered the items (which could be picked up) by exploring. Then I produced a list of instructions to automate this all-item-pickup stuff, then played around a bit with combos before writing some code to automate the checking of combinations after realising I wouldn't get there by playing. The code is here: https://github.com/smcl/aoc-2019-xmas


2019-12-24 - Planet of Discord

Day 24 puzzle input is a (mine is here) sort of cellular automata system. Part 1 involves running the system until a certain calculation (called "biodiversity") returns a value previously seen. Part 2 involves modifying this to be weirdly recursive in a way that is too complex to summarise in a single sentence (check the linked problem definition).


2019-12-23 - Category Six

Day 23 puzzle input is an IntCode program (mine is here) which represents a networked computer as part of a bigger network. Part 1 involves connecting a number of these network computers, running them and finding the first packet sent to computer 255. Part 2 involves modifying the behaviour so that computer 255 does something when the network is "idle" (no packets are sent) which kicks things into action again, and finding the first y value sent to this computer twice in a row.


2019-12-22 - Slam Shuffle

Day 22 puzzle input is an set of instructions on how to shuffle a set of cards (mine is here). Part 1 involves performing the shuffle according to these instructions and finding the card at index 2019. Part 2 involved performing this shuffle for an insanely huge deck, many times over. This involved something I had never seen before, so I ended up consulting the reddit and to be honest I still don't properly get it.


2019-12-21 - Springdroid Adventure

Day 21 puzzle input is an IntCode program (mine is here) which represents a networked computer as part of a bigger network. Part 1 involves connecting a number of these network computers and finding the first


2019-12-20 - Donut Maze

Day 20 puzzle input is a donut-shaped maze (mine is here) with numerous entrances both on the inside and outside of the maze. Part 1 involves finding the shortest path from node "AA" to "ZZ". Part 2 involves assuming the maze has some weird recursion (going into the inside exit "AA" results in you appearing in entrance "ZZ" ... but in another "dimension". You have to find the shortest path from AA to ZZ in the same dimension, but you can traverse different dimensions.


2019-12-19 - Tractor Beam

Day 19 puzzle input is an IntCode program (mine is here) which will models a sort of beam, and when provided with an x/y co-ordinate will output whether the beam is in effect at that position. Part 1 involves finding the number of positions for x and y in the range 0-49 which are affected by the beam. Part 2 involves figuring out the first 100x100 section which can be wholly contained within the beam (position of the top-left corner).


2019-12-18 - Many-Worlds Interpretation

NOTE: Incomplete!!!

Day 18 puzzle input is a maze (mine is here) where capital letters represent doors, that require keys (lower case letters) to open (i.e. you need to collect "a" if you want to traverse through door "A"). Part 1 involves finding the fastest route through this maze to collect all keys. Part 2 involves splitting the maze into quadrants and having four different things moving through the maze. Ugh.

I kind of hated this one too - it's like travelling salesman if after visiting a node the graph changed :-/


2019-12-17 - Set and Forget

Day 17 puzzle input is an IntCode program (mine is here) which will output a camera's viewpoint of a twisting, turning "scaffold" with a little robot at one end. Part 1 involves finding the locations of all places where this scaffold intersects another. Part 2 involves "programming" the robot to make its way over the scaffold from start to finish (the commands are quite limited) and finding the output value at the end of this.


2019-12-16 - Flawed Frequency Transmission

Day 16 puzzle input is a long sequence of digits (mine is here) which represent a noisy input signal from a sensor. Part 1 involves applying an algorithm to process the signal and generate an output signal and returning the first 8 digits of it. Part 2 involves applying the same algorithm to your signal repeated 1000x its original length, and taking the first 8 digits (after a 7 digit offset, which is the first set of value in the signal). I did not like this one.


2019-12-15 - Oxygen System

Day 15 puzzle input is an IntCode program (mine is here) which controls a droid that should perform some repairs on an oxygen tank. Part 1 involves using the program to explore the surroundings (it's basically a maze), find a destination (an oxygen tank) then find the shortest path to that location. Part 2 involves exploring the maze, then simulating the spread of oxygen through the maze and finding how many time-steps it would take to fill every spot of the maze.


2019-12-14 - Space Stoichiometry

Day 14 puzzle input is a set of sequences (mine is here) like "10 ORE => 10A", which would mean "You can produce 10 of resource 'A' using 10 of the'ORE' resource". Part 1 involves using these reactions to determine the minimum amount of ORE required to produce 1 "FUEL". Part 2 involves going the other way - finding how much FUEL you can produce with 1 trillion ORE.


2019-12-13 - Care Package

Day 13 puzzle input is an IntCode program (mine is here) which represents a game similar to arkanoid/breakout, and outputs a sequence of commands which can be interpreted to draw a game state. Part 1 involves initializing the game and counting the number of "block" tiles that are on screen. Part 2 involves actually playing the game until you break all the blocks and finding your score.


2019-12-12 - The N-Body Problem

Day 12 puzzle input is the position and velocity of a number of moons (mine is here but I didn't want to write any parsing code and it's only 4 lines so I have inlined it in my solution below). Part 1 involves calculating the movement of these moons over 1000 "steps" and applying a calculation to return the "energy" in the system. Part 2 involves attempting to find how many steps it would take for all of the moons to return to their original positions.


2019-12-11 - Space Police

Day 11 puzzle input is an IntCode program which is supposed to control a little robot that paints the surface of a ship (mine is here). Part 1 involves running the program and keeping track of the number of panels it paints. Part 2 involves running the program over a panel coloured white, keeping track of what the robot paints - which should spell out a registration number.

Note: this is one of the ones I disliked because a few instructions were rather vague and weirdly worded, like this:

The panel under the robot (not visible here because a ^ is shown instead) is also black, and so any input instructions at this point should be provided 0.

This "provided N" appears a few times in the text.


2019-12-10 - Monitoring Station

Day 10 puzzle input is a matrix of "#" (a position containing an asteroid) and "." (a position with no asteroids) which represent a map (mine is here). Part 1 involves identifying a location which has direct line of sight to the most asteroid positions. Part 2 involves finding the co-ordinate of the 200th asteroid that would be destroyed by a spinning laser mounted at the station.


2019-12-09 - Sensor Boost

Day 9 puzzle input is IntCode program called "BOOST" which is a test that the IntCode CPU is operating correctly (mine is here). Part 1 involves running the program with a given input until it succeeds and outputs a code. Part 2 involves running this program with a different input - it'll output another code.


2019-12-08 - Space Image Format

Day 8 puzzle input is a stream of digits that supposedly represent an image in layers (mine is here). Part 1 involves finding the layer with the fewers "0" digits and multiplying the number of "1" occurrences by the number of "2" occurrences. Part 2 involves interpreting and decoding the image.


2019-12-07 - Amplification Circuit

Day 7 puzzle input is an IntCode program that that produces an output based on its input values (mine is here). Part 1 involves figuring out which inputs produce the largest output value. Part 2 is similar, except you configure the IntCode cpu slightly differently and run it many times - to find the largest output. AoC describes it better than I can :-)


2019-12-06 - Universal Orbit Map

Day 6 puzzle input is a number of string pairs, which represent objects which orbit each other (mine is here). Part 1 involves figuring out how many objects are directly or indirectly orbiting each other in total. Part 2 involves treating this as a graph and finding the shortest path from/to a given object.


2019-12-05 - Sunny with a Chance of Asteroids

Day 5 puzzle input is a list of integers which are instructions for a program which will run on the processor we started writing a few days before (mine is here). Part 1 involves adding a bit more functionality to the interpreter we wrote and finding what the output is if we send 1 as the input to the program. Part 2 involves adding still more functionality and finding what is output if we send 5 as input.


2019-12-04 - Secure Container

Day 4 puzzle input is a pair of integers which represent a range of integers (mine is 256310-732736). Part 1 involves filtering integers in these range according to a handful of specified rules and counting how many integers satisfy these conditions. Part 2 is the same but with one additional rule.


2019-12-03 - Crossed Wires

Day 3 puzzle input is two sequences of direction/length pairs which represent the winding paths of two wires (mine is here). Part 1 involves finding the "manhattan distance" between the start point and the point where they intersect which is closest to the start. Part 2 involves finding the shortest path to this point from the center.


2019-12-02 - 1202 Program Alarm

Day 2 puzzle input is a list of integers which represent opcodes which comprise a small program (mine is here). Part 1 involves writing an interpreter for these opcodes and finding the result. Part 2 involves finding values you can swap into the second and third positions of the code result in the largest output value.


2019-12-01 - The Tyranny of the Rocket Equation

Day 1 puzzle input is a list of integers which represent weight of some modules on a spacecraft (mine is here). Part 1 involves applying a calculation to the weight to determine how much fuel is required, and summing up all fuel requirements Part 2 is an adjusted version of this calculation to take on board the fact that fuel adds weight that needs to be carried.