Files
2024-01-24 19:52:36 +01:00

1.1 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
6557743527cb92a06417ea97 Schritt 21 20 step-21

--description--

Create a for loop to iterate over your graph, and append each node to the unvisited list.

--hints--

You should create a for loop to iterate over graph inside the shortest_path function.

({ test: () =>  {
    const shortest = __helpers.python.getDef(code, "shortest_path");
    const {function_body} = shortest;    
    assert(function_body.match(/^(\s*)for\s+(\w+)\s+in\s+graph\s*:/m));
  }
})

You should append each node to unvisited inside your for loop.

({ test: () =>  {
    const shortest = __helpers.python.getDef(code, "shortest_path");
    const {function_body} = shortest;    
    assert(function_body.match(/^(\s*)for\s+(\w+)\s+in\s+graph\s*:\s*^\1\1unvisited\.append\s*\(\s*\2\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 = []
--fcc-editable-region--