Delivery Drone Delivery Drone

Nowadays the drones are working in transportation. (Delivery drone(Wikipedia)) Let's make a plan to ensure the efficient drone movement.

The input value is a list of integers. One or more numbers of this list represent the existence of the package(s) to be transported and its destination. You have to return the shortest moving distance for the drone to complete all transportation as an integer.

  • Note:
    • The drone is initially at position 0 (far-left position).
    • The drone can carry only one package at a time.
    • You can drop the package only at the destination point.
    • You aren't forced to pick up the package at the destination point.
    • The drone returns to position 0.


delivery_drone([0, 2, 0]) == 4
delivery_drone([0, 0, 1, 2]) == 6

Input: The information about the packages (a list of integers).

Output: The shortest moving distance (an integer).


  • 3 ≤ len(input) ≤ 30
  • 1 ≤ number of packages ≤ 9