Advent of Code - 2019 - Day 7 - 8

The seventh problem was yet another twist of the Intcode machine. This time we needed to handle multiple “processes” where output from one process was wired to input of another process. To achieve this I had to do a bit of refactoring since now execution of a program must be able to stop and wait for more input. The problem was more tedious than challenging - and in the end part 2 could be run in around 15 seconds.

Today’s solution puts the Intcode machine in a separate namespace which simplifies the code a bit.

My solution is here

2 Likes

The eighth problem came down to turning a very large number (or a stream of digits, depending on your interpretation) into image layers. Part 1 was to produce a strange checksum and part 2 was to flatten the image layers, getting rid of transparent pixels.

Normally you’d processed the input by turning it into a list of characters, but that doesn’t really fly in Sophia. So instead I made use of the fact that we have unbound integers and represented the input as a huge number and produces the layers and individual pixels by div and mod. Not the most efficient, but a straightforward solution that ran in 2 and 6 seconds respectively for part 1 and 2. I was bit short on time, so this solution isn’t very optimized, nor very elegant. But still a 15000 digit integer is pretty cool :slight_smile:

My solution is here

1 Like