Skip to content
Snippets Groups Projects
Commit 3a9dcb6c authored by Kraijenoord's avatar Kraijenoord
Browse files

20191201

parent 4517d053
No related branches found
No related tags found
No related merge requests found
#This is the first assignment for advent of code
print ('hoi')
def main():
filepath = "1-dec-input.txt"
print(filepath)
# open the input file
TotalFuel = 0
with open(filepath) as fp:
for total, line in enumerate(fp):
ModuleFuel = calcFuel(int(line.rstrip()))
FuelFuel = calcExtraFuel(ModuleFuel)
print ("Zo veel Fuel voor de module en de fuel: " + str(ModuleFuel) + " : " + str(FuelFuel))
TotalFuel = TotalFuel + ModuleFuel + FuelFuel
print ("Zo veel in Fuel voor de mass: " + str(TotalFuel))
def calcFuel(intMass):
return (int(intMass/3)) - 2
def calcExtraFuel(intMass):
RemainderFuel = 0
ExtraFuel = intMass
while ExtraFuel > 0:
ExtraFuel = max(0, calcFuel (ExtraFuel))
RemainderFuel = RemainderFuel + ExtraFuel
return RemainderFuel
if __name__=="__main__":
main()
#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.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment