11
1
Have you ever found a good challenge to answer, answered it and then found out somebody posted a solution with a better score in the same language?
Challenge
Write a program/function that takes a PPCG question ID and outputs a leaderboard.
A leaderboard consists of the rank, the language, the score, the author and the URL of each answer. This can be output as a newline delimited string, a list of strings, a "dictionary", etc..
- Rank
- The rank of an answer is its position in the score hierarchy (lowest first).
- Answers with shared scores must have the same rank.
- Language
- The name of the language is always between the last
#
on the first line and the first,
. - It may be a link to documentation, which must be handled by taking the user-facing text.
- The name of the language is always between the last
- Score
- The score of a answer is the last number on the first line.
- It may be a decimal number.
- Author
- The author of an answer is the display name of the user that posted it.
- URL
- The URL of an answer will go straight to the answer.
- URL shorteners are disallowed.
Specifications
- Standard I/O rules apply.
- Standard loopholes are forbidden.
- This challenge is not about finding the shortest approach in all languages, rather, it is about finding the shortest approach in each language.
- Your code will be scored in bytes, usually in the encoding UTF-8, unless specified otherwise.
- Explanations, even for "practical" languages, are encouraged.
Test cases
Note that these show example output formats which need not be strictly followed. These examples were taken at the time of sandboxing, they might be outdated.
Input: 28821
1. PCRE flavor, score 40 by jimmy23013 (https://codegolf.stackexchange.com/a/31863)
Input: 92944
1. Jelly, score 12 by Dennis (https://codegolf.stackexchange.com/a/92958)
2. Befunge-98, score 38 by Hactar (https://codegolf.stackexchange.com/a/98334)
3. ><>, score 41 by Sp3000 (https://codegolf.stackexchange.com/a/92980)
4. TovTovTov, score 810147050 by Yaniv (https://codegolf.stackexchange.com/a/93048)
Input: 47604*
1. Pyth, score 28.08 by Jakube (https://codegolf.stackexchange.com/a/47642)
2. APL, score 39.6 by jimmy23013 (https://codegolf.stackexchange.com/a/47606)
Input: 133793
1. Lua, score 9.06 by TehPers (https://codegolf.stackexchange.com/a/135775)
2. C# (.NET Core), score 10.20 by Kamil Drakari (https://codegolf.stackexchange.com/a/135764)
3. Cubically, score 86.98 by Kamil Drakari (https://codegolf.stackexchange.com/a/137695)
*Note that this challenge has 3 answers, however the GolfScript answer doesn't have a comma in the header which makes it undefined behaviour.
In a few better formats:
28821, 92944, 47604, 133793
28821 92944 47604 133793
28821
92944
47604
133793
Is using libraries allowed? For example the HTML Agility Pack for C#.
– Ian H. – 2017-08-07T07:34:22.097@IanH. That is the same as always, you can use libraries but make sure to specify that in the header. Wouldn't want it to mislead people on leaderboards. ;) – totallyhuman – 2017-08-07T07:43:52.870
Does the PPCG default leader board count as a language? If yes does it count as 1 byte? :P – TheLethalCoder – 2017-08-07T08:58:53.307
@TheLethalCoder You can golf the stack snippet and post it as a JS answer (no, it does not count as 1 byte :P). However, I'm sure you guys can come up with more interesting answers. – totallyhuman – 2017-08-07T13:03:58.233
@Downvoter Do you, you know, have a reason to downvote? Just curious... – totallyhuman – 2017-08-07T13:37:06.957
3I like your title :P – Daniel – 2017-08-07T14:31:14.207
Also, is
12.000000
ok instead of12
because of fickle float precision? – Daniel – 2017-08-07T21:01:57.467@Dopapp Yes, that is fine. – totallyhuman – 2017-08-07T21:02:29.223
For questions that contain answers with poorly formed headers (as in test case 47604), is the allowance for undefined behaviour applied just to those answers or does it cover the full output for the question? How should outputs that contain answers with the same score be numbered? Consider, for an example, a question with 2 answers sharing second place, should the ranking go
1,2,2,3
or1,2,2,4
or is either acceptable? – Shaggy – 2017-08-08T10:42:23.580@Shaggy Undefined behaviour only for the answer with a bad header. Both
1,2,2,3
and1,2,2,4
are acceptable but they must share the rank if they share scores. – totallyhuman – 2017-08-08T12:39:19.547