Well I’m only 13 days late, but better late than never. I had some time to kill tonight and decided to finally jump on this year’s advent of code. Each day consists of 2 problems that you solve. So here goes Day 1.
Part 1
Santa has become stranded at the edge of the Solar System while delivering presents to other planets! To accurately calculate his position in space, safely align his warp drive, and return to Earth in time to save Christmas, he needs you to bring him measurements from fifty stars.
Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck!
The Elves quickly load you into a spacecraft and prepare to launch.
At the first Go / No Go poll, every Elf is Go until the Fuel Counter-Upper. They haven’t determined the amount of fuel required yet.
Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2.
For example:
- For a mass of 12, divide by 3 and round down to get 4, then subtract 2 to get 2.
- For a mass of 14, dividing by 3 and rounding down still yields 4, so the fuel required is also 2.
- For a mass of 1969, the fuel required is 654.
- For a mass of 100756, the fuel required is 33583.
The Fuel Counter-Upper needs to know the total fuel requirement. To find it, individually calculate the fuel needed for the mass of each module (your puzzle input), then add together all the fuel values.
What is the sum of the fuel requirements for all of the modules on your spacecraft?
The data input was a list of 100 random numbers. This was a pretty simple problem (really just a little math). There were a number of ways that it could be solved and I was feeling pretty lazy so I decided to just use excel to solve it.
I pasted the list of input values into a column (column A) and then in each cell in column B, I entered the following formula =ROUNDDOWN(A1/3,0)-2. If you’re not familiar with the rounddown function, it simply takes a number an rounds it down (regardless of what the actual number is) to a certain position. I put this formula on each row, and then did an autosum which gave me a total of 3318195.
Part 2
The Elves quickly load you into a spacecraft and prepare to launch.
At the first Go / No Go poll, every Elf is Go until the Fuel Counter-Upper. They haven’t determined the amount of fuel required yet.
Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2.
For example:
- For a mass of 12, divide by 3 and round down to get 4, then subtract 2 to get 2.
- For a mass of 14, dividing by 3 and rounding down still yields 4, so the fuel required is also 2.
- For a mass of 1969, the fuel required is 654.
- For a mass of 100756, the fuel required is 33583.
The Fuel Counter-Upper needs to know the total fuel requirement. To find it, individually calculate the fuel needed for the mass of each module (your puzzle input), then add together all the fuel values.
What is the sum of the fuel requirements for all of the modules on your spacecraft?
I kept building off of what I had already done with my spreadsheet for this one. Next to my initial calculation that I had done for Part 1, I added a new formula =IF(ROUNDDOWN(B1/3,0)-2 >= 1,ROUNDDOWN(B1/3,0)-2,0). What this does is once again figures out how much fuel is required for that amount of weight using the same rules as above. If that number is greater than or equal to 1, then it uses that number. If it is 0 or smaller, it uses 0. I put those across 17 columns just to make sure there was enough room, and then summed up each row, and then the final column to get a total of 4974428.