Implement a program that finds the shortest path of links between one Wikipedia URL and another.
You can imagine the final result is something similar to https://www.sixdegreesofwikipedia.com/
Part 1 – pass test cases 1-3B (crawl distance < 3)
Part 2 – pass test cases 3C-4B (crawl distance 3)
Don’t worry about input validation or parsing – assume the input will always be a valid Wikipedia page name.
async def find_degree_of_separation(page1: str, page2: str) -> float:
Return the shortest directed path between one article and another.
Return -1 if either article is not a valid Wikipedia article or there is no connection between them.
Assume that the longest distance between any two Wikipedia articles is 6.
This problem asks you to compute the shortest directed link distance between two Wikipedia articles, which is a classic shortest-path search on a graph. Each article is a node and each internal link is a directed edge, so the goal is to find the minimum number of clicks from page1 to page2, returning 0 when the pages match and -1 when no connection exists. A breadth-first search is the natural approach, ideally with deduplication and caching of fetched links to avoid revisiting pages. The note about a maximum distance of 6 suggests a bounded search depth.