Files
2024-05-22 17:27:37 +02:00

1.0 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
655773f8b8b5db9fc6d0ae76 Step 25 20 step-25

--description--

To keep track of the visited nodes, you need a list of all the nodes in the graph. Once a node is visited, it will be removed from that list.

Now, replace the pass keyword with a variable named unvisited and assign it an empty list.

--hints--

You should have a variable called unvisited inside the shortest_path function.

({ test: () => assert(runPython(`_Node(_code).find_function("shortest_path").has_variable("unvisited")`)) })

You should assign an empty list to your unvisited variable. Remember to delete pass.

({ test: () => assert(runPython(`_Node(_code).find_function("shortest_path").find_body().is_equivalent("unvisited = []")`)) })

--seed--

--seed-contents--

--fcc-editable-region--
my_graph = {
    'A': [('B', 3), ('D', 1)],
    'B': [('A', 3), ('C', 4)],
    'C': [('B', 4), ('D', 7)],
    'D': [('A', 1), ('C', 7)]
}

def shortest_path(graph, start):
    pass
--fcc-editable-region--