Remove cargo stuff for rust and add python implementation
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
def calculate_fuel(mass):
|
||||
return mass // 3 - 2
|
||||
|
||||
def calculate_fuel2(mass):
|
||||
fuel = mass // 3 - 2
|
||||
if fuel < 0:
|
||||
return 0
|
||||
else:
|
||||
return fuel + calculate_fuel2(fuel)
|
||||
|
||||
if __name__ == '__main__':
|
||||
with open('../input') as f:
|
||||
content = f.readlines()
|
||||
|
||||
modules = [int(x.strip()) for x in content]
|
||||
|
||||
fuel1 = [calculate_fuel(x) for x in modules]
|
||||
fuel2 = [calculate_fuel2(x) for x in modules]
|
||||
|
||||
print("Solution for Part One: ", sum(fuel1))
|
||||
print("Solution for Part Two: ", sum(fuel2))
|
||||
Reference in New Issue
Block a user