# Day 10 of Advent of Code

It has been a few days since I posted, mostly working on Advent of Code

###### ## Day 6 – Universal Orbit Map

Today’s challenge gave a list of paired values. On the right is the child and the left the parent. So it was a matter of parsing the list and finding all the unique values not including the root. I then used that li t to traverse the list recursively counting up the parents. The second part had you count the jumps from YOU to SAN. Here I used the previous code to build two new lists, one for YOU and one for SAN. I then took the lists and created a new list of the intersection. The first value in the list is the common point. So then count up the pairs until the target is found for both lists, and add them together, subtract 2 from the total as we don’t need to include the starting pairs.

###### ## Day 7 Amplification Circuit

We continue with using the computer from days 2 and 5. This time we have to feed the output to another copy of the int computer as an amplifier to “amplify” the thrust 5 times suing a sequence. The sequence is all the permutations of 0,1,2,3,4 to find the maximum thrust. The second part you then have feed the output from the last amplifier into the first amplifier until that finishes to get a thrust value. The loop through all permutations of 5,6,7,8,9 until the max value is found. On the first part I had a bit of a problem understanding the example data, until I realized that was just another version of the int computer and the sequence to get the max thrust. I should have understood it, but as usual I try to over complicate things. On the second part I had separate the int computers, which I put in a list, so I had an list of lists.
I then created as amplifier id and a list of positions for each amplifier. I also set up a way to accept input for the sequence once. I still have a bug involving one of the examples in part2. I had missed an increment for the position that had caused infinite loops. I still have infinite loops in second example. My code does work for getting the correct value for the part 2 today, but I think I may spend some time getting the other example to work, since some of the challenges rely on previous challenges. I found my problem I was not continuing to run until all the “amplifiers” halted.

###### ## Day 8 – Space Image Format

Today was pretty straight forward. Although if it says fewest and you provide most you don’t get the answer correct. That was the first part. The second part all I had to do was render and image, but I swapped the X,Y positions while loading a grid. I knew it was a simple error. When I think of an X and Y coordinates I think X should be first then Y, but for putting in a two dimensional array I put the Y first. I mixed them up when loading the array. So no matter how much I tried to debug the code further down the line I could not find a problem. Eventually I checked the code from the beginning. I should remember that going forward but I won’t.

###### ## Day 9 – Sensor Boost

This is another modification and run of the INT computer. I decided to refactor my code. I am not sure how many more times we will be using the INT computer from days 2 and 5, so cleaner code will hopefully help. Once I got that done I reran all the examples and data from day 5. I could now tackle today’s challenge. Today we had to add a new mode and opcode. The opcode was fairly easy but the mode was quite different. This new mode is called relative and was not hard to implement on the opcode input parameters but was a little confusing on the output parameter. Stepping through my code I found that is was not updating the correct location which clued me in to changing the output parameter logic. Once I passed the final example I passed part1. Part 2 was just to rerun it with a different input code.

###### ## Day 10 – Monitoring Station

The challenge is to find an asteroid that can monitor the most other asteroids. I figured out what I needed to do but forgot about having to take in account when calculating slope that you need to also know the quadrant. Part two involved systematically destroying the asteroids and find out which one with the 200th.
I knew what I had to do but again which trig function was the right one, and how was it implemented. I will have to learn more about Python itertools, collections and the math library.