Files
2024-05-29 10:06:17 -07:00

1.4 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
65577739f57ecca6c39bb4e9 Крок 33 20 step-33

--description--

Конструктор list() дозволяє створити список з ітерованого об’єкта.

Змініть присвоєння змінної unvisited, використовуючи list(), та передайте graph як ітерований об’єкт.

--hints--

Використайте list(), щоб створити список зі словника graph.

({ test: () =>  {
    const shortest = __helpers.python.getDef(code, "shortest_path");
    const {function_body} = shortest;    
    assert(function_body.match(/list\s*\(\s*graph\s*\)/));
  }
})

Призначте list(graph) до unvisited.

({ test: () =>  {
    const shortest = __helpers.python.getDef(code, "shortest_path");
    const {function_body} = shortest;    
    assert(function_body.match(/unvisited\s*=\s*list\s*\(\s*graph\s*\)/));
  }
})

--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 = {}

    print(f'Unvisited: {unvisited}\nDistances: {distances}')

shortest_path(my_graph, 'A')
--fcc-editable-region--