You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
329 B
17 lines
329 B
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)
|
|
|