DEV Community

Discussion on: Advent of Code 2019 Solution Megathread - Day 1: The Tyranny of the Rocket Equation

Collapse
 
fossheim profile image
Sarah

I joined the leaderboard, but since I'm in a EU timezone and only have time to work on them in the evenings I'm expecting my scores to be quite low 😅

Here's my solution for day 1 with Python (explained my thinking behind it here):

Part 1:

input = np.array([input])
output = np.sum(np.floor(input / 3) - 2)

Part 2:

for module in input_array:
    new_fuel = mod
    while True:
        new_fuel = np.floor(new_fuel / 3) - 2
        if new_fuel > 0:
            total_fuel += new_fuel
        else:
            break