Advent of Code - 2019 - Day 11 - 12

The eleventh problem was yet another
usage of the Intcode machine. This time though the problem was merely using
it, so no changes necessary to that part. The task was to build a painting
robot, that moved along an infinite grid, running an Intcode program for each
square deciding on the color of the square and the direction to turn in. For
part 1 you only had to count the number of squares that was painted but for
part 2 we needed to display what was painted so some rudimentary string
processing was done in Sophia!

220> aefa_sophia_test:run_file("/Users/hans/Personal/Repos/AoC2019/11/sol_11.aes", "solve_1", []).
5568706 steps / 4264437725 gas / 237784397 reductions / 6976.82ms
2319
221> aefa_sophia_test:run_file("/Users/hans/Personal/Repos/AoC2019/11/sol_11.aes", "solve_2", []).
747875 steps / 62233696 gas / 30851420 reductions / 636.95ms
[<<" #  # #### ###  ###  ###  ####  ##    ##   ">>,
 <<" #  # #    #  # #  # #  # #    #  #    #   ">>,
 <<" #  # ###  #  # #  # #  # ###  #       #   ">>,
 <<" #  # #    ###  ###  ###  #    # ##    #   ">>,
 <<" #  # #    # #  #    # #  #    #  # #  #   ">>,
 <<"  ##  #### #  # #    #  # #     ###  ##    ">>]

My solution is here

1 Like

The twelfth problem was about tracking objects in 3D, though the physics was a bit simplistic. The naive solution (after some tweaking) worked ok for part 1. For part 2 a better algorithm was needed, but still the problem is expensive to solve in Sophia. I think it can be further optimized, however to get the runtime down to seconds will not be easily done.

16> aefa_sophia_test:run_file("/Users/hans/Personal/Repos/AoC2019/12/sol_12.aes", "solve_1", []).
0 steps / 174491485 gas / 0 reductions / 1993.96ms
{tuple,{7471,
        [{tuple,{{tuple,{-51,-12,-9}},{tuple,{6,8,-9}}}},
         {tuple,{{tuple,{59,-6,-27}},{tuple,{6,1,4}}}},
         {tuple,{{tuple,{21,-60,12}},{tuple,{-20,-9,-4}}}},
         {tuple,{{tuple,{0,81,21}},{tuple,{8,0,9}}}}]}}
20> aefa_sophia_test:run_file("/Users/hans/Personal/Repos/AoC2019/12/sol_12.aes", "solve_2", []).
0 steps / 1652188028015 gas / 0 reductions / 224605.71ms
376243355967784

My solution is here