mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-12 10:00:39 -04:00
974 B
974 B
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 655776db1eeae0a620e42a0d | Крок 31 | 20 | step-31 |
--description--
Тепер викличте функцію, передавши my_graph та 'A' як аргументи.
--hints--
Викличте shortest_path, передавши my_graph та 'A' як аргументи.
({ 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--