Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Delivery Drone by Tinus_Trotyl
from typing import List
from itertools import permutations
def delivery_drone(orders: List[int]) -> int:
distance = 0
for workflow in permutations(package for package in orders if package):
moves, position = 0, 0
for package in workflow:
pickup = orders.index(package)
moves += abs(pickup - position) + abs(package - pickup)
position = package
moves += position
distance = min(distance, moves) if distance else moves
return distance
July 31, 2019