best_tour_length = infinity for each possible ordering of the houses tour_length = 0 for i in range[1,n-1] tour_length = tour_length + distance(house[i], house[i+1]) tour_length = toure_length + distance(house[n], house[1]) best_tour_length = min(best_tour_length, tour_length)