|
1234567891011121314151617181920212223 |
- 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 = [(x//3) - 2 for x in masses]
- newfuels = []
- for fuel in fuels:
- of = fuel
- f = fuel
- while f > 0:
- af = (f//3) - 2
- if af > 0:
- of += af
- f = af
- else:
- f = 0
- newfuels.append(of)
- #print(newfuels)
- print(sum(newfuels))
-
- if __name__ == "__main__":
- main()
|