I want my program to construct a path using a best first(greedy) strategy (i.e the next point picked to be in the path will be the one closest to the current point), from a given list of lists of distances, where distances[i][j] is the distance between point i to point j.
I have an issue in a fragment of my code which is responsible for finding the lowest dist:
for i in range(len(pointsLeft) - 1):
if i in pointsLeft and i not in path: #only looks at points still not in path
lowDist = distances[lastPoint][i]
nextDist = distances[lastPoint][i + 1]
if nextDist < lowDist:
lowDist = nextDist
I noticed that for the first few loops the code works correctly, but then it finds the wrong min value.