python advanced 2026-11-24 को समाप्त

Shortest delivery route (Dijkstra)

A delivery company stores its road network as a dict: graph[a][b] = minutes (one-way roads). Write shortest_route(graph, start, goal) that returns (total_minutes, [start, ..., goal]) for the fastest route.

  • Return (None, []) when the goal can't be reached.
  • start == goal returns (0, [start]).
  • Nodes that only appear as destinations are valid nodes.
  • It must be fast: the last test has 2,000 nodes. Use a priority queue (heapq).

Acceptance criteria

  • Ties may return any one of the fastest routes; the tests only check routes that are unique.
  • The tests at the bottom print All tests passed.

अब तक 0 लोगों ने हल किया।

python
एडिटरCtrl + Enter

            
        

जब टेस्ट "All tests passed" दिखाते हैं, तो चैलेंज इस ब्राउज़र में हल के रूप में चिह्नित हो जाता है।

अपना समाधान समीक्षा के लिए भेजें