Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- inputFile = open("modules.txt", "r")
- outputFile = open("answer.txt", "w")
- sum = 0
- for i in inputFile:
- mass = int(i)
- fuel = (math.trunc(mass/3))-2
- fuelTotal = fuel
- while (fuel > 0):
- fuel = (math.trunc(fuel/3))-2
- if (fuel > 0):
- fuelTotal = fuelTotal + fuel
- sum = sum + fuelTotal
- outputFile.write(str(sum))
- inputFile.close()
- outputFile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement