initial commit

This commit is contained in:
s-prechtl 2022-12-09 08:29:06 +01:00
commit 27fe77bbe1
134 changed files with 21939 additions and 0 deletions

24
2021/Day7/Day7.py Normal file
View file

@ -0,0 +1,24 @@
import sys
def calcFuelCost(steps: int):
total = 0
for cost in range(1, steps + 1):
total += cost
return total
if __name__ == '__main__':
with open("input.txt", "r") as f:
crabs = [int(x) for x in f.read().strip().split(",")]
minFuel = sys.maxsize
for i in crabs:
totalfuelcost = 0
for x in crabs:
totalfuelcost += calcFuelCost(abs(x - i))
minFuel = min(totalfuelcost, minFuel)
print(minFuel)