This blog post is a work in progress
Project website: Advent of Code 2019.
Previous years: 2015, 2016, 2017, 2018.
I use Perl for all the solutions.
Most assume the input data is in a file called input.txt
in the same
directory as the file.
A note on scoring
Current score (2020-12-25): 46. I’m aiming for a final of 44+1.
I score my problems to mark where I’ve finished a solution myself or given up and looked for hints. A score of 2 means I solved both the daily problems myself, a score of 1 means I looked up a hint for one of the problems, and a zero score means I didn’t solve any of the problems myself.
My goals for this year (in descending order of priority):
- get 38 stars or more (75%)
- solve all problems within 24 hours of release
TODO
- complete day 18
Day 1 - Day 2 - Day 3 - Day 4 - Day 5 - Day 6 - Day 7 - Day 8 - Day 9 - Day 10 - Day 11 - Day 12 - Day 13 - Day 14 - Day 15 - Day 16 - Day 17 - Day 19 - Day 20 - Day 21 - Day 22 - Day 23 - Day 24 - Day 25
Day 1 - The Tyranny of the Rocket Equation
A nice and simple problem to kick off this year.
Score: 2
Day 2 - 1202 Program Alarm
An earlier appearance of register rodeo than expected! I think we’ll see more of this going forward.
[intcode
part 1]
Score: 2
Day 3 - Crossed Wires
This took longer than it had to. I messed up adding the paths, and only managed to get the correct answer to part 1 by chance. Once I plotted the example data I could correct the code, then add the logic for part 2.
I’m not entirely happy with the duplicated direction subroutines. Some people have used complex numbers to simplify this but that would require a separate Perl module to implement.
Score: 2.
Day 4 - Secure Container
I blanked on this one and dreaded combinatorics. Turns out brute force
is eminently doable. Credits to
/u/andreyrmg
in the daily solutions thread, and A_D
and sim642
in the IRC
channels for help in inspiration.
I still think my solution is my own though (and pretty Perlish), so full score today.
Score: 2.
Day 5 - Sunny with a Chance of Asteroids
After struggling with the convoluted problem description I was pleasantly surprised to find my code ran flawlessly first try. I still have some niggling issues with the test data, and need to clear that up before the inevitable next intcode
problem.
[intcode
part 2]
Score: 2.
Day 6 - Universal Orbit Map
I bailed on this one and sought inspiration in the daily solutions subreddit. Credit in source!
Score: 0.
Day 7 - Amplification Circuit
A tough, but fun one. There were a lot of subtleties in the second part, and I got some pointers from the subreddit.
I got the chance to clean up my intcode
implementation, and learned a new facet of Perl.
[intcode
part 3]
Score: 2.
Day 8 - Space Image Format
Defying expectations (and maybe fears), this Sunday problem was not that complicated.
Of course, it helps if you confirm that what you think is input actually is the same as the problem input. Not that I’d have anything other than theoretical knowledge of this situation…
Score: 2.
Day 9 - intcode test suite
Day 9 - complete solution Day 9 - complete solution
So the Intcode computer is done, and we’ve amassed a number of test cases to ensure it works. I’m kinda sorta happy with my code. It’s not the most elegantly put together but it works fine.
[intcode
part 4]
Score: 2.
Day 10 - Monitoring Station
This was a fun one, even though I got sidetracked by my incorrect assumptions and got lost in a hallway of indices, all alike.
Part 2 was found by inspecting the output, but hey, a star is a star.
Score: 2.
Day 11 - Space Police
Ah, the return of Langton’s ant. Always nice to see an old friend.
Nothing too complex here, although I’m quite proud of the line noise for the dispatch table for movement:
my %directions = (
'^'=>sub{!$_[0]?['<', 0,-1 ]:['>', 0, 1 ]},
'<'=>sub{!$_[0]?['v', 1, 0 ]:['^',-1, 0 ]},
'v'=>sub{!$_[0]?['>', 0, 1 ]:['<', 0,-1 ]},
'>'=>sub{!$_[0]?['^',-1, 0 ]:['v', 1, 0 ]},
);
[intcode
part 5]
Score: 2.
Day 12 - The N-Body Problem
A fun little problem.
Score: 2.
Day 13 - Care Package
I am in awe of what the creator of Advent of Code has wrought in the form of intcode
.
[intcode
part 6]
Score: 2.
Day 14 - Space Stoichiometry
A hard problem that was satisfying to solve.
Score: 2.
Day 15 - Oxygen System
Not my proudest moment. I’m happy my intcode
implementation works well enough for this kind of application now, but my utter inability to code a BFS routine is humiliating. In the end I had to use a modified Djikstra’s that I cribbed for last year’s day 22.
[intcode
part 7]
Score: 2.
Day 16 - Flawed Frequency Transmission
Day 16 - part 1 Day 16 - part 2
I had a lot of trouble with part 2, mostly due to indexing errors.
Runtime is 2m16s for part 2, which is just barely acceptable.
Score: 2
Day 17 - Set and Forget
This one was a slog!
I was very worried that my intcode
interpreter was incorrect, but it was actually just me not being able to read the input specification correctly.
[intcode
part 8]
Score: 2.
Day 19 - Tractor Beam
This was supposed to be a breather…
From the beginning I realized that this problem is best expressed as x in terms of y, instead of the more usual y in term of x, and I made a mental note not to mix them up.
Of course, many hours later I realized I had done that just that.
[intcode
part 9]
Score: 2.
Day 20 - Donut Maze
Part 1 yields easily to a modified BFS approach.
Update 2020-12-26
Part 2 is similar, only adding the “dimension” of the recursive level. There some really scruffy code to figure out the “edges” of the transition.
Score: 1.
Day 21 - Springdroid Adventure
I felt zero interest in trying to puzzle this out so found some closed forms on the subreddit.
[intcode
part 10]
Score: 0.
Day 22 - Slam Shuffle
Part one only done for now, part 2 requires way too much weird (read modular) math for me. Damnit, Cap’n, I’m continuous, not discrete!
Score: 1.
Day 23 - Category Six
A remarkably straight-forward puzzle.
[intcode
part 11]
Score: 2.
Day 24 - Planet of Discord
Day 24 - part 1 Day 24 - part 2
An interesting problem.
Update 2020-12-25 I revisited this after the multiple Games of Life in 2020. Instead of trying to be clever figuring out how to calculate the neighbors, I just created a giant lookup table.
This Reddit post contains all iterations of the example input and was helpful for debugging.
Score: 2
Day 25 - Cryostasis
A fitting end to a good edition of Advent of Code!
Score: 2.