Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Optimize Aptive Technician Route

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Optimize Aptive Technician Route. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Aptive Environmental wants to optimize a simplified technician schedule for a single day. Given travel times between stops, implement a function that returns the minimum total travel cost to start at the Aptive branch, visit every assigned stop exactly once, and return to the branch.

Formal Specification

Write a function optimize_aptive_route(travel_times) where:

  • travel_times is an n x n matrix of non-negative integers
  • travel_times[i][j] is the cost to travel from stop i to stop j
  • stop 0 is the Aptive branch (start and end)
  • the function returns an integer: the minimum possible total route cost

If travel_times is empty, return 0. If the matrix is not square, contains negative values, or has inconsistent row lengths, raise ValueError.

Constraints

  • 0 <= n <= 12
  • travel_times is an n x n matrix
  • 0 <= travel_times[i][j] <= 10^6 for valid inputs
  • Stop 0 is the Aptive branch and must be the start and end
  • The matrix may be asymmetric

Function Signature

def optimize_aptive_route(travel_times):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output