Advent of Code – Day 12

So almost half way through the Advent of Code. The last couple of days had me chasing down bugs in my code.

 

## Day 11 – Space Police

We use the int computer again today. Somehow I broke the input code and took quite a bit of time to figure out my error. The int computer still ran but gave the wrong output. I did output the data to an image file. The weird thing is that I new the answer to the second part first, because it jumps to the part 2 code in the int computer and then ignores all other input.

## Day 12 – The N-Body Problem

Today’s part 1 challenge is to calculate the gravity and velocity of four moons and then output the total energy.
Part 2 involved looping through the process until x,y,z each reached their orginal postions and velocity. However that could take a long time so the Least Common Multiple was the answer.
So you could just find the first time x returned, then y and then z. Then calculate the Least Common Multiple.