parent
a152cec986
commit
8a13d3912c
1 changed files with 17 additions and 0 deletions
@ -0,0 +1,17 @@ |
|||||||
|
positions = [int(i) for i in open("input.txt", 'r').read().split(",")] |
||||||
|
|
||||||
|
width = max(positions) |
||||||
|
bestFuel = len(positions)*width |
||||||
|
bestPos = 0 |
||||||
|
|
||||||
|
for i in range(bestFuel): |
||||||
|
fuelUsed = 0 |
||||||
|
for pos in positions: |
||||||
|
fuelUsed += abs(i - pos) |
||||||
|
if fuelUsed > bestFuel: |
||||||
|
break |
||||||
|
bestFuel = fuelUsed |
||||||
|
bestPos = i |
||||||
|
|
||||||
|
print(bestFuel) |
||||||
|
print(bestPos) |
Loading…
Reference in new issue