22
3
July 1st is Canada day (yay Canada)! Or is it? It seems that the Wikipedia page for this day has a lot of Canada related content, but is there another day which is more Canadian?
Your task is to write a program or function which takes a date (month and day) as input and returns or outputs the number of mentions of "Canada" on the Wikipedia page for the inputed date. Some rules:
- Dates may be input in any reasonable format of your choice
- Your submission must pull data from the url
en.wikipedia.org/wiki/Month_Day
. - Only
"Canada"
must be searched for and counted included substrings, and only in title case."Canadian"
does not count, however"Canada's"
does count. As long as the exact, case-senstitive text"Canada"
exists within a string, it is a match - Contents of the page are considered anything within the corresponding
.html
file (i.e. what shows up if you download as page as a.html
and open it in Notepad) - Result may be output to STDOUT, returned, or displayed in any other reasonable manner
Test Cases:
July 1 => 34
May 14 => 1
Oct 31 => 2
July 4 => 2
This is code golf, so shortest submission wins
(As an unrewarded bonus, I'm interested to see what the day with the highest count is)
Can the Wikipedia API be used? – LegionMammal978 – 2016-07-05T17:14:19.540
I don't know much about it, so I'm hesitant to say yes in case there is a trivial function to it. Use your best judgement and if it makes it too easy please abstain – wnnmaw – 2016-07-05T17:16:26.030
9
So references to Canadaville, Canadair, Canadarm, Canadaga, Canadarago, Canaday, Canadaspis, et al. count?
– msh210 – 2016-07-05T17:21:56.217@msh210, Yep, that they do – wnnmaw – 2016-07-05T17:23:12.670
Everyone is using enwp.org in here – None – 2016-07-06T06:23:20.453
1July 1 is the day with the highest count! Wrote a quick program for it, though it isn't golfed. – Andrew – 2016-07-06T12:10:17.627
@MatthewRoh, yes, but that redirects to the required url, so I'm allowing it – wnnmaw – 2016-07-06T13:42:51.850