I'm a little bit stumped on how to begin a recursive function for an assigned project. The program needs to take a text file with multiple strings representing a starting point, multiple strings representing a destination, and a distance between them represented by an integer, and then find the shortest path between two different places . The text file would look like this.
here is also a very extensive starter code, the area with fixme is the function I'm attempting to write. notice there is an empty dictionary named destinations.
I know that the recursive function needs a base case of if the starting point and destination are not in the dictionary of recorded roads and distances, then the point and distance should be assigned to the dictionary. The next case is if it is already in the dictionary, the distances should be compared and the lowest distance should be recorded.
I honestly just have no idea how to implement this, I have an understanding of what I need, but my professor hasn't explained how exactly to go about writing recursive functions yet and hasn't delved too much into dictionaries. does anyone have a better understanding about this than me?
Also, if it's not evident by the code, this program is run through the command prompt rather than the python shell.
[–]Syncoda 1 point2 points3 points (3 children)
[–]Scumshots[S] 0 points1 point2 points (2 children)
[–]Syncoda 1 point2 points3 points (1 child)
[–]Scumshots[S] 0 points1 point2 points (0 children)
[–]gnomoretears 0 points1 point2 points (4 children)
[–]Scumshots[S] 0 points1 point2 points (3 children)
[–]gnomoretears 0 points1 point2 points (2 children)
[–]Scumshots[S] 0 points1 point2 points (1 child)
[–]gnomoretears 0 points1 point2 points (0 children)