21
\$\begingroup\$

Rosetta Code collects solutions to standard programming exercises in hundreds of programming languages. However, it focuses on "good" or idiomatic solutions in those languages. I'm not aware of a similar catalogue from a golfing perspective. Is PPCG capable of fulfilling that role? Do we have challenges for standard programming exercises, where the answers can act as a catalogue of the shortest possible solution in each language? I know Anarchy Golf contains leaderboards for all the languages it supports, but the solutions aren't disclosed.


Long story short, of course I know we do. However, we only recently started emphasising the catalogue nature of challenges corresponding to simple (and common) tasks. There are many more such tasks which

  • Have never been asked on PPCG without any fancy extras like before.
  • Have been asked before, but where the challenge is not particularly well-specified and could use an overhaul.
  • Have been asked before, but could use some love to include the leaderboard to generate the actual catalogue more easily.

This post (with its answers) is an effort to organise existing and upcoming catalogues a bit. We have talked about this in chat a few times, and the general consensus seems to be that a) these challenges need extra care if they are supposed to be good references and b) they shouldn't be posted too often, e.g. not more than one every other week, because they take a lot of effort from the community to be filled with a large number of answers.

This is not supposed to be a sandbox for catalogue-type challenges. This is rather intended to compile an overview of what has been done and what is still left to do. Whenever we pick a particular challenge from the list, it should still be fleshed out in the normal sandbox.

\$\endgroup\$
10
  • \$\begingroup\$ This sounds like an excellent idea to me. I'll be watching this post to see what others think. \$\endgroup\$ Oct 19, 2015 at 18:07
  • 1
    \$\begingroup\$ What is the goal of these catalogs? Who are they for? \$\endgroup\$
    – xnor
    Oct 20, 2015 at 5:04
  • \$\begingroup\$ Most challenges on Anarchy Golf reveal their answers after the deadline (post mortems); only about 1/4 of challenges are hidden forever. \$\endgroup\$
    – xnor
    Oct 20, 2015 at 5:06
  • \$\begingroup\$ @xnor Well I guess they are for people interested in golfing and programming languages. :P For instance, before posting the HW catalogue, I had a hard time finding the shortest known Hello World in something as (reasonably) popular as Brainfuck. They also serve as a platform for quirkier esolangs where solving trickier tasks than standard programming exercises is near impossible. Finally, they should also act as high-quality dupe targets for simpler challenges which new users might occasionally repost. \$\endgroup\$ Oct 20, 2015 at 6:11
  • \$\begingroup\$ @xnor Put differently, I'm hoping that PPCG can be one of the most important sites for the code golf community (if there is such a thing), and to that end it would be great if covered standard tasks with high-quality specifications and a broad coverage of programming languages in order to become a valuable reference. Stack Exchange is still about building great content after all, right? ;) \$\endgroup\$ Oct 20, 2015 at 8:33
  • 5
    \$\begingroup\$ @ETHproductions British spellings (-ise instead of -ize) are not typos. Martin already made that clear in preferring the spelling of "fulfil" (British) over "fulfill" (American). Thus, I rolled back your edit. \$\endgroup\$ Oct 22, 2015 at 6:39
  • 2
    \$\begingroup\$ @ChrisJester-Young Thanks. I realised that after the fact. I had originally changed fulfil as well, but then I saw his rollback. I live in the US, so I'm not used to any of these spellings. I'll remember about this in the future. \$\endgroup\$ Oct 22, 2015 at 13:13
  • \$\begingroup\$ I've noticed recently that several users have been posting catalogue challenges seemingly without permission, and sometimes 2 or 3 have been posted in a week. So, I have a few questions: 1) Have these users obtained permission, either in the Sandbox or somewhere else? 2) If so, why are they being posted at this relatively fast rate? 3) Will they be included in the official list of existing catalogues? \$\endgroup\$ Nov 18, 2015 at 16:20
  • \$\begingroup\$ @ETHproductions I'm not exactly sure what kind of permission they require. Anyone is free to post whatever challenge they want. Of course it would be nice if people sandboxed a challenge that they think might make a good future reference, but if they don't and it's not a close-worthy challenge, what can we do? If the challenges are actually decent and accumulate answers in a large number of languages, they will be included here. \$\endgroup\$ Nov 18, 2015 at 16:23
  • \$\begingroup\$ Ok, that makes sense. Thanks! \$\endgroup\$ Nov 18, 2015 at 16:25

3 Answers 3

21
\$\begingroup\$

Yes. But not with catalog questions.

The idea of catalogs was a noble one, but having seen it play out in practice, I think it's done more harm than good.

"This is a catalog question" was used to defend poor questions, ones that I'd expect to be downvoted for being simply a race to post in most languages, or closed for being basically covered by existing questions. Instead, because of the flawed way HNQ promotes questions for being easy, they got masses of upvotes and attention and answers.

Moreover, the label "catalog" has confused people into thinking that other questions don't care about answers in many languages, only the single shortest solution over all languages.

These problems aren't fundamental to the idea of catalogs, just how people have (mis)used them. I think they could be useful for questions specifically tailored to be a repository of standard building blocks.

Yet, given the pitfalls of catalogs, I think it's better we strive for their goals in challenges in general, without a label. Every challenge should encourage participation in a variety of languages, be complete and well-written as a definitive spec for that challenge, and attract well-golfed answers that could be used as a reference for golfing other challenges if relevant. (Language-specific challenges and the like are exceptions.) None of these require a new category of challenge, just care to the challenges we're already making.

\$\endgroup\$
1
  • 6
    \$\begingroup\$ Thanks for writing up the post I've been meaning to write for two weeks. :) \$\endgroup\$ Dec 8, 2015 at 7:02
13
\$\begingroup\$

Existing Catalogue Challenges

This post lists all the challenges which already act as a catalogue. Currently these are only the few which have explicitly been posted with that goal in mind. Requirements for being added to this list include that the task should be a common programming exercise, the challenge post includes a Stack Snippet to generate a leaderboard and the answers should cover at least 50 languages.

In chronological order:

(I am intending to amend this answer with a Stack Snippet which generates some data across all catalogues, including their relative completeness and a table listing the shortest solution per language in each challenge.)

\$\endgroup\$
1
  • 2
    \$\begingroup\$ In case anyone was curious, I just went through these challenges and edited the snippets of some. Language names starting with lowercase letters were consistently shoved to the bottom of the "alphabetically" sorted list; this was due to JS's assumption that 'Z' < 'a', since it sorts by char codes. \$\endgroup\$ Nov 4, 2015 at 19:25
10
\$\begingroup\$

Future Catalogue Challenges

This post collects ideas for future catalogue challenges. Some of these tasks already have challenges, some of which may be editable into a catalogue while others may not.

Existing challenges that could be catalogues

In these cases, the OP's should be asked whether they are okay with some thorough editing to the challenge (which shouldn't invalidate any serious answer). Then the format of the spec could be adjusted to make it more similar to the other catalogues, a leaderboard would be added, and the headers of the answers adjusted.

  • Fibonacci. (From day 1!) Looks quite good. Chris gave his permission to edit the challenge, so this one is about to be turned into a catalogue.
  • Reverse STDIN. Looks quite good.
  • Factorial. Looks quite good.
  • Quine. This actually already acts as the best quine catalogue I know. In principle it should be fairly easy to turn this into a decent catalogue with a leaderboard snippet, but the tricky thing here is sorting out what we actually consider to be a proper quine.
  • Shortest code producing infinite output. As the pendant to "Shortest infinite loop producing no output".

Existing challenges that could be redone as catalogues

  • Binary search. The challenge is wrapped in a very specific context that doesn't lend itself well to a generic binary search challenge.
  • Levenshtein distance. A challenge that doesn't ask for the intermediate outputs might be more useful as a catalogue and more golfable.
  • Game of Life. Despite the look of it, this is not a plain code golf, but rather a in disguise.
  • Palindrome checker. The challenge isn't bad but it contains a lot of very specific rules which go against the defaults we're using today. As a catalogue challenge one could also simplify the specification and make all characters in the string count (instead of ignoring everything except letters).
  • ...

New challenges

  • A plain array sorting challenge. We've had challenges for a few specific algorithms and one for sorting strings, but I can't find anything about "sort an array of integers". I also wonder if it might be better to collect different sorting algorithms separately.
  • 99 Bottles of Beer. We've had two s but no code golf.
  • ...
\$\endgroup\$
3
  • \$\begingroup\$ I think it would be interesting to divide various sorting algorithms into separate challenges. The sorting builtins in many languages choose an appropriate algorithm rather than always using the same one. I'd be interested in developing a sorting catalog challenge. \$\endgroup\$
    – Alex A.
    Oct 20, 2015 at 17:01
  • \$\begingroup\$ @AlexA. Alternatively, one could have a single challenge, and answer header include both a language and the sorting algorithm used. Then the leaderboard would be able to sort by both of those. \$\endgroup\$ Oct 20, 2015 at 17:02
  • \$\begingroup\$ That's a good idea. That would probably be better than a bunch of separate catalogs by algorithm. \$\endgroup\$
    – Alex A.
    Oct 20, 2015 at 17:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .