"All roads lead to Rome" is a saying that essentially means there are plenty of different ways of achieving an objective.
Your task is to write a program that finds a set of link connections from one Wikipedia page to the Wikipedia page about Rome.
Notice that it is not enough to find the word
Rome with a hyperlink,
Rome has to be linked to this specific page:
The Wikipedia pages are written in HTML, a markup language. With the appropriate syntax, a word or phrase can be annotated and turned into a hyperlink, which allows people to click the word/phrase and open a new Wiki page. You can see a couple of such link in the screenshot below:
Those annotated hyperlinks are what your program should locate and follow. To try and avoid some loopholes, we are going to restrict the links you are allowed to follow to the links within the
content, which is roughly this part of the wiki page:
You are only allowed to query Wikipedia wiki pages on the internet. Your answer may not communicate with anything else. E.g., you are not allowed to download someone else's answer and run it.
You may not communicate with any wiki APIs or Wiki "meta" pages, such as the "Category" page.
This community is very clever and imaginative. As more loopholes arise, those may be explicitly disallowed in the challenge. The spirit of the challenge is to find a series of links a user could click in the content of wiki pages.
Your code should take one of the two as input:
- a string that, when appended to
https://en.wikipedia.org/wiki/, gives a valid link to a valid Wikipedia page;
- a string with the link already built for you.
You may assume there is a valid path between the input page and Rome's page.
Your program should output the path taken so that the lengths you claim are actually verifiable. It is up to you to output the path in any way that is human readable and understandable. Some suggestions include:
- the successive path links
- the successive page names
This is code-golf, so we care about byte count. You are allowed to define a string literal containing exactly these characters in this order:
"https://en.wikipedia.org/wiki/" and not count it for the byte count of your program.
At the time of writing, these pages had a 1-link path to Rome:
"https://en.wikipedia.org/wiki/Italy" "https://en.wikipedia.org/wiki/A.S._Roma" "https://en.wikipedia.org/wiki/Vatican_Hill" "https://en.wikipedia.org/wiki/Europe" "https://en.wikipedia.org/wiki/European_Union"
And these pages had a path of length at most 2 to Rome:
(feel free to suggest more!)
Please submit your code with a screenshot or a TIO link showing a path from a Wikipedia page of your choosing to Rome.