mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-02 02:01:39 -05:00
910 B
910 B
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 655776db1eeae0a620e42a0d | Step 26 | 20 | step-26 |
--description--
Now, call your function passing my_graph and 'A' as the arguments.
--hints--
You should call shortest_path passing my_graph and 'A' as the arguments.
({ test: () => assert.match(code, /^shortest_path\s*\(\s*my_graph\s*,\s*("|')A\1\s*\)/m) })
--seed--
--seed-contents--
my_graph = {
'A': [('B', 3), ('D', 1)],
'B': [('A', 3), ('C', 4)],
'C': [('B', 4), ('D', 7)],
'D': [('A', 1), ('C', 7)]
}
--fcc-editable-region--
def shortest_path(graph, start):
unvisited = []
distances = {}
for node in graph:
unvisited.append(node)
if node == start:
distances[node] = 0
else:
distances[node] = float('inf')
print(f'Unvisited: {unvisited}\nDistances: {distances}')
--fcc-editable-region--