Now below is a dictonary, I am trying find the shortest path.we have to go to all 5 houses based on shortest time. Each key is a house, each list of values is the time in seconds. For example, the first house has a time of 0 because it's obvious, now from 1st house to second house has 74 seconds... and so on. Each index is a time represenation to the next house.
now second row, with 2 as key. from second house to first house it's 74 seconds, and now from 2nd house to third house it's 4069 seconds as show below.
I am trying to find the best algo for this i am confused what should i use? combinations? permutations?
The goal is to find the shortest path FROM house to house with represetation below and SUM of all time traveld in the shortest path you find
list = 0, 74 , 2213, 816, 1172 ,
The shortest path.
1 -> 2 -> 5 -> 4 -> 3 -> 1
WE HAVE to return to first house again thats why 1 is shown again
numbers 1 through 5, represents houses list
go through each key,value find the minimum and index of the min. Add the time to a time_list
access the next home(keys) with the index found in previous
match the index of min to the next home, in the home ignore zero and the times already encounters in previous home times
combinationsandpermutationsactually do and from the results figure out which one makes more sense here?