Advent of Code 2019 - Day 13

Note: This topic is to talk about Day 13 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:

39276-eeb74f9a

1 Like

A+++++++ would solve again!!1

I used a few simple IO.ANSI calls to display every screen change. Very entertaining!

Day 13 Part 2

The ball can become invisible. How strange… At the very least, it happens with my input.

This was fun, and easier than I expected. Here’s the code:
https://git.sr.ht/~ihabunek/aoc2019/tree/master/lib/day13.ex

1 Like

I made a video of the game being played:
https://asciinema.org/a/iCFURolasxTLhQsXCYll9rmKk

4 Likes

The most entertaining day so far -> solution

This is also the first day I am using my package, intcode to process the program.

Here’s my take.

Got to my solutions very quickly, though it part 2 tricked me… I just looked at the score when I was asked for input. Though the program tells you the final score without waiting for any input…

My solution. Today was fun!

My solution

For part2 I made a printout as its running. Disable this to run faster :slight_smile:
Here is a screenshot:

1 Like

Today was the best! I ended up implementing the whole game in interactive mode with ncurses support (which I had never used before) and it freaking rules. Then I plugged an “AI” back in it to beat the game while I watch and get the final score.
I actually had a lot of fun with this one. Great job to the intcode computer too!

2 Likes

Just finished it. It was indeed really fun :slight_smile:
What kind of performance do you have? (when running headless). Mine takes about 12s to complete
My solution: https://github.com/cblavier/advent/blob/master/lib/2019/day13/part2.ex

I had problem with part 2 in the morning. The paddle would miss the ball and the would be lost almost immediately. It turned out that I updated the joystick state both when the score was received and when the ball was painted. Removing the update when the score was received fixed the problem.

Since I was late with posting anyway, I decided to do some clean up. I rewrote part 1 to use the same play bot as part 2, and inspired by @aaronnamba’s use of IO.ANSI I added a mix task to show an animation of game being played. To run the animation, just type mix animate.

My solution.

Both parts finish in 0.3 seconds.

1 Like

:sob:

Let’s go back to work then!

It’s 3.5s for part 2 on my office VM. Have no further data points for comparing.

Part 1 runtime is negligible.

1 Like

It’s worthy to mention that all puzzles don’t take the time processing time

Still my implementation is the slowest and don’t find any obvious improvement. I’m wondering if the process + message passing implementation for the Intcode machine is suboptimal :thinking:

My puzzle input is available in the linked repository, you coul test your implementation against my import to determine if it was my machine or your input that made the difference. I can’t test your input on my implementation on my machine before Monday though.

It’s actually what I did against your puzzle (my previous post wasn’t clear).
It took 6sec on your puzzle whereas my puzzle took 12seconds.

But I’m still looking for optimization … nothing obvious yet

From a first glance over your code, pulling inputs one by one and handling them one by one seems costly.

I’m on a year’s end party of my office at the moment, but I’ll try to compare your input to mine on my home laptop tomorrow and post the result here.

1 Like