16
1
Write a program or a function that outputs the integer number of answers this question has. Your solution should still work as more answers are added.
Languages that run in a browser may be run from the js console while on this page. Otherwise, you'd probably have to download this page. Multi-language solutions, e.g. wget
ing the page and parsing it using grep
is ok. Just sum up the command line and all source used.
This is code golf; shortest answer in bytes wins.
EDIT:
Let's allow at most one occourance of the url of this page to not count, either as input or in the source. No url shorteners, no data stored as get parameters etc. Quotes around url, if needed, still count. Taking the url as input is also fine. If you want to remove some part of the url, e.g. /how-many-answers...
, you can, but it probably doesn't help you.
It's probably too late to rule on this now, but should the count include deleted answers? – Dennis – 2016-10-15T15:28:48.247
2@Dennis I cannot see deleted answers, so I would say nobody has to worry about them. Count them if you want to. I won't count them since I cannot see them. – Filip Haglund – 2016-10-15T15:32:14.277
Can the function accept the url as an input? Would the input then count towards the bytecount? – JungHwan Min – 2016-10-15T16:22:59.777
@JHM yes and yes – Filip Haglund – 2016-10-15T20:46:41.370
@JHM or maybe no, as Dennis points out below one of the answers, it's unfair against browser code to count the url's. If that's the case, then I'd say url constants maybe shouldn't count either. What do you people think? – Filip Haglund – 2016-10-15T20:51:37.723
Please define "output". Do you mean that it returns that integer, or that it outputs the integer in a human readable format? – Makyen – 2016-10-15T21:59:46.413
2@FilipHaglund, I think that it would make most sense to have the URL byte count in the code be subtracted from the total count or have it be taken as input because that sort of makes it impossible for languages that don't run in the browser to have a chance at winning – Daniel – 2016-10-15T23:09:27.870
@Dopapp Subtract from byte count is slippery. Some languages have ways to compress the URL. – Dennis – 2016-10-16T03:03:31.580
@Dennis, then maybe it could optionally be taken as input? – Daniel – 2016-10-16T03:04:17.880
1That (although in some languages taking input could require even more bytes) or only allow to subtract if the URL
http://...
appears verbatim in the source code. – Dennis – 2016-10-16T03:05:38.717@Mayken when the code is executed, I want to see "9" on the screen. If you use a repl, return values are fine, since it prints them to the screen. Also ints vs strings; both are fine (but please don't output quotation marks). – Filip Haglund – 2016-10-16T07:56:08.080
Let's allow at most one occourance of the url of this page to not count, either as input or in the source. No url shorteners, no data stored as get parameters etc. Quotes around url, if needed, still count. Taking the url as input is also fine. If you want to remove some part of the url, e.g. /how-many-questions..., you can, but it probably doesn't help you. – Filip Haglund – 2016-10-16T08:03:38.353
You should add that to the question. This comment is hidden by default, so not everybody will see it before answering. – Dennis – 2016-10-16T14:32:19.207
-1, not enough jQuery in all those answers. – Blackhole – 2016-10-16T18:56:52.140