12345678910111213141516171819202122232425 |
- def main():
- #lines = [12, 14, 1969, 100756]
- with open("01ain.txt", "r") as file:
- lines = file.readlines()
- masses = [int(x) for x in lines]
- fuels = [getFuel(x) for x in masses]
- newfuels = []
- for fuel in fuels:
- of = fuel
- f = fuel
- while f > 0:
- f = getFuel(f)
- of += f
- newfuels.append(of)
- #print(newfuels)
- print(sum(newfuels))
-
- def getFuel(f):
- fuel = (f//3) - 2
- if fuel > 0:
- return fuel
- return 0
-
- if __name__ == "__main__":
- main()
|