Colleagues told me "the Advent of Code is a marathon". By now I’m certainly feeling that.
I’ll share a bit of my experience in this blog post.
This is my first year participating in the Advent of Code (AoC), and I must say it’s a lot of fun. My personal goal is to ‘save Christmas’ using Go, which is a relatively new language for me.
Calculating chemical reactions, traversing graphs, solving a maze with breadth-first search… I’ve already (re-)learned a lot, and I feel participating in the advent of code using a new language is maybe the best programming boot camp there is. The creator, Eric Wastl, seems to have given all puzzles a great deal of attention, and there’s often some backstory related to the history of computer science.
The complexity of the puzzles can get you into the woods really quickly. One of the things that really helped me is testing. Writing proper tests helps tremendously in debugging, especially if you find yourself modifying the same piece of code several times over. Another thing that seems to be a bit of a recurring theme is visualization. This makes it easy to figure out whether the 90 degrees you’ve set is actually ‘down’ instead of ‘up’ :).
Traversing the scaffold
Today we dusted off the Intcode program again. The Intcode program takes a set of integers as instructions and executes different functions based on those instructions.
To be fair, it didn’t really collect much dust. This home-built virtual machine has been used in painting our spaceship, playing a game of breakout, and finding an oxygen machine in a maze… Now, we’ve got to navigate a scaffold with a vacuum robot.
I feel participating in the advent of code using a new language is maybe the best programming boot camp there is.
The first part of the puzzle is figuring out where the intersections are. My algorithm simply figures out whether there’s a ‘#’ surrounding the examined tile.
The second part is more difficult: now we need to actually traverse all tiles in the path and see how much dust the vacuum will collect. Because I’m a bit short on time today, I opted to get the pen and paper out and wrote down the steps the robot should take. This involved figuring out three basic patterns, since the robot could only take a limited set of movement commands. Next, I got the ASCII table out to get the commands to the robot in the correct format. Add a small bit of logic, and boom, there goes part two!
Another one down..
It’s not the solution I’m most proud of. Ideally I’d have invested in a solution that could handle other scaffolds as well, but oh well… Running a multiple-day marathon means you might have to go for the less pretty option sometimes.
If you’re doing all of the puzzles later, though, just believe me when I say that it’s worth it to invest some extra time in the Intcode program 😉.
Advent of Code 2019 Series
- Advent of Code 2019 Has Started – Join In!
- Advent of Code 2019 – Day 2
- Advent of Code: How Excel Made My Day and Saved My Son’s Day Too
- Advent of Code – Day 4: Visualize
- Advent of Code – Day 5: Saintaerkla2s
- Advent of Code – Day 6: How I Got Hooked on AoC
- Advent of Code – Day 7: Share Your Workflow
- Advent of Code – Day 8: How Simple Things Can Be Very Hard for Some People
- Advent of Code – Day 9: How I Started Enjoying Solving Programming Puzzles
- Advent of Code – Day 10: Space Cowboys Shooting Pixels in the Sky
- Advent of Code – Day 11: To Be or Not to Be
- Advent of Code – Day 12: Shooting for the Moon
- Advent of Code – Day 14: Chain Reaction
- Advent of Code – Day 16: Curses
- Advent of Code – Day 17: Vacuuming a Scaffold with the Intcode Program
- How Little Green Men Helped Me Solve a Puzzle
- Advent of Code – Day 20: A Little Bit of Revision
- Advent of Code – Day 21: It’s a Marathon, Not a Sprint
- Advent of Code – Day 22: Shuffling Cards Until Eternity
- Advent of Code – Day 23: The Network is Reliable
- Advent of Code – Day 24 & 25: Think Out of the Box