Your question is Count URLs Matching Domain. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Anthropic's Claude documentation tooling represents a crawlable web as an in-memory graph. Given a domain, a starting URL, and a mapping of pages to their outgoing links, count the number of unique reachable URLs that belong to the domain.
Use breadth-first or depth-first traversal. A URL belongs to domain when its hostname is exactly domain or is a subdomain of it. For example, docs.anthropic.com belongs to anthropic.com, but notanthropic.com does not. Ignore URL fragments when determining whether two URLs are the same, so https://docs.anthropic.com/a#intro and https://docs.anthropic.com/a#usage represent one URL. The input contains absolute HTTP or HTTPS URLs.
Implement count_domain_urls(pages, domain, main_url).
pages is a dictionary mapping a URL string to a list of absolute URL strings. A URL absent from pages has no outgoing links.domain, main_url, and all URL keys and links are strings.main_url, including main_url when it matches the domain.def count_domain_urls(pages, domain, main_url):