You are viewing a single comment's thread. Return to all comments →
Python 3
def truckTour(petrolpumps): N = len(petrolpumps) for i in range(N): j = 0 tank_cap = 0 valid_tour = True while j < N: liters, dist = petrolpumps[(j + i) % N] tank_cap += liters - dist j += 1 if tank_cap < 0: valid_tour = False break if valid_tour: return i
Seems like cookies are disabled on this browser, please enable them to open this website
Truck Tour
You are viewing a single comment's thread. Return to all comments →
Python 3