Was it Really Canada Day?
Bash, 43 42 40 bytes
curl -L enwp.org/$@|grep -o Canada|wc -l
Uses curl
, grep
, and wc
to count occurrences of "Canada" in specified webpage. Like the other answers, input is given in the format July_1
. This is my first time posting on the Code Golf SE and I'm not quite familiar with all of the rules. Any feedback would be most welcome.
Didn't realize that output to STDERR
is traditionally ignored. Thanks for the 3 bytes, Dennis!
Perl 5, 39 bytes
38 bytes, plus 1 for -pe
instead of -e
$_=()=`curl -L enwp.org/$_`=~/Canada/g
Takes input like July_1
.
Thanks to busukxuan for saving me seven bytes.
Python 3.5, 117 111 98 90 bytes
(-8 bytes (98 -> 90
) thanks to alexwlchan)
from urllib.request import*
lambda i:urlopen('http://enwp.org/'+i).read().count(b"Canada")
Simply uses Python's built-in "urllib" library to fetch HTML data and then counts the occurrences of the word "Canada" in that data. Will try and golf more over time where and when I can. Call it by renaming the lambda
function to anything and then calling that name like a normal function wrapped in print()
. For instance, if the function were named H
, then you would call it like print(H(Month_Day))
.