# Advent of Code - 2019 - Day 13 - 14

The thirteenth problem was a game, namely `Breakout` of course implemented in `Intcode`. Part 1 was simple, run the program and check the output (the game board). Second part was more fun, play the game, what is the winning score!? I first tried to do it interactively, but since you need somewhere around 4500 steps to finish the game the handling of state trees, etc. killed that approach. Instead I implemented a simple AI in Sophia and let it play the game to completion. This took around 90 seconds, but who is in a hurry

``````8> aefa_sophia_test:run_file("/Users/hans/Personal/Repos/AoC2019/13/sol_13.aes", "solve_1", []).
0 steps / 108454225 gas / 0 reductions / 3164.72ms
296
9> aefa_sophia_test:run_file("/Users/hans/Personal/Repos/AoC2019/13/sol_13.aes", "solve_2", []).
0 steps / 87460100420 gas / 0 reductions / 92794.62ms
{tuple,{16,16,16,13824}}
``````
1 Like

The fourteenth problem was about chains of “chemical” reactions to create rocket fuel. The main complication was to keep track of surplus material when reactions where not one-to-one. The task was to find out how much ore was required to make 1 unit of fuel. For part 2 the problem was reversed, given X ore how much fuel could be produced. Due to the surplus material it isn’t linear, and the best way to approach it was to implement a binary search over the solution to part 1. I.e. find the amount of fuel that would require just below X ore. With some small optimizations (only traverse lists once, etc.) it ran to completion in about 10 seconds.

``````59> aefa_sophia_test:run_file("/Users/hans/Personal/Repos/AoC2019/14/sol_14.aes", "solve_1", []).
0 steps / 762793 gas / 0 reductions / 140.31ms
598038
60> aefa_sophia_test:run_file("/Users/hans/Personal/Repos/AoC2019/14/sol_14.aes", "solve_2", []).
0 steps / 1343915935 gas / 0 reductions / 10722.23ms
2269325
``````