Advent of Code 2019 - Day 11

Note: This topic is to talk about Day 11 of the Advent of Code 2019.

There is a private leaderboard for elixirforum members. You can join it by following this link and entering the following code:


1 Like

Today was nice. Here’s my solution, which has a pure functional intcode interpreter (i.e. no spawning and message passing), and a robot abstraction built on top of it. The run loop is implemented with streams.


Here’s my solution.

Little to highlight, I just used message passing and with as fundamental. And a little bit of math to rotating vectors to refactor.



Here is my solution :

I was really happy to use my Day9 message passing computer,. Unlike yesterday, this puzzle was really easy for me, and I’m surprised that after 10 days of coding, I feel adventofcoding already made be a better programmer!


My solution here. I definitely have to fix my painting implementation, since it is a mess. Also I now want to refactor my Intcode.

1 Like


Positions are represented as complex numbers (specifically, {a, b} tuples representing real and imaginary part). Moving can be done by addition: position + direction.

Rotation of direction is implemented by means of multiplication of a direction vector by either i or -i (complex number multiplication by value within unit circle can be used to represent rotation). Because there is no particular need to have full complex multiplication merely for that - the only possible parameters are i and -i, it’s special-cased for only those two parameters (makes code a little bit simplier). Much easier than implementing a state machine representing the directions and transitions between those.


Hi! First post on this forum. :slight_smile:

Here’s my solution, pretty similar to Sasa’s:

The intcode machine remains unchanged since day 9:

I’m happy that I remembered to use with where it made sense.


Mutually dependent processes! IntCode meets a custom finite state machine (FSM), in what I can only say is a problem where I didn’t really get the problem definition so I just started writing what the spec told me to do and it eventually worked.
I think my solution using message-passing for IO and multiple processes ends up being rather elegant! Source code (including intcode interpreter):


Today’s puzzle was fun. My initial solution gave the wrong answer because of a bug in how I handled the communication between the Intcode machine and the robot, so I decided it was time to start using processes. I solved both parts this morning before going to work, but I thought that my solution needed some cleaning up and elimination of some Erlangisms (using the :io module instead of the IO module) before pushing it.

In the cleaned up version, I broke out the Intcode interpreter into a separate module.

Here is my solution.


My code

Struggled for hours, then figured out I had mixed up the order of the outputs from the intcode program :stuck_out_tongue:

1 Like

My solution.

I initially wrote the part 2 solution upside down. I was thinking, “b isn’t a capital letter.” But P is! :slight_smile:

1 Like

A bit late to todays hull painting, but as I have started to rewrite my VM from close to scratch, which only finished yesterday, I didn’t find the necessary time to solve the problem.

Though I did not even read the problem description until after the VM was rewritten, and I have rewritten it especially with problems as todays in mind. So I was able to solve Day 11 both parts without even touching the VM code:

Day 11
The big merge commit from wipe to ready

1 Like