Two recent code-golf questions have proceeded nicely until an accepted answer is chosen

collatz-conjecture - originally the asm answer was accepted, now a shorter solution is accepted, but not the shortest by far

triforce - asm answer is accepted even though it's one of the longest.

I think the problem is summed up by this comment

@Kamarey: No, I think there's more to code golf than that. Language comparisons for one. Show off your skill at programming (could you show me a programmer who doesn't?). Clever implementations. etc. Would the person who wrote the python interpreter have to include that code if they posted a python version? I could create a new languauge, triforce for example, that has a single letter command which implements a solution to this problem - should I include the language code or could I claim a result of 1 char (golfscript anyone?) On this site, I think size is less important. But what do I know? – Skizz Mar 12 at 9:37

There seems to be a meme on SO that code-golf is about "cool-code" or "clever-code"

So what should be done about these questions. The code-golf tag no longer applies so should it be removed? I think then all the golfed answers will look silly.

Are cool-code or clever-code tags considered too subjective for SO?

  • 6
    There is a meme on SO that "code golf" belongs elsewhere. – nb69307 Mar 17 '10 at 21:27
  • @Collatz hey that's me! – Earlz Mar 17 '10 at 21:44
  • 1
    @earlz, heya. Code-golf is barely tolerated on SO as it is. I am worried that if people get mixed up idea what code-golf means it will give a strong argument to stop tolerating it altogether. Read the stuff of meta to find out more about the history/status of code-golf on SO – gnibbler Mar 17 '10 at 21:55
  • 2
    @Henk: Code golf isn't (and never has been) about the most readable answer. It's about the shortest answer that solves the problem. Yes, that nearly always means that the winning answer would be the most dense. – Chris Jester-Young Mar 17 '10 at 22:08
  • @Henk: There are ways to state which answer you like, without ruining the spirit of code golf. See stackoverflow.com/questions/62188/stack-overflow-code-golf/… for an example of how I handled it (arguably one of the earliest and most-viewed code golf questions on SO). – Chris Jester-Young Mar 17 '10 at 22:40
  • @Chris. I think it's more about the most clever way to make the code short and not a measure of how verbose the language is. – Earlz Mar 17 '10 at 23:05
  • 1
    @earlz: Unfortunately for you, sites like anarchy golf (golf.shinh.org) and codegolf.com don't agree. Granted, they also have intra-language scoreboards, so 10,000 points is awarded to the shortest program in a given language, but in the global inter-language scoreboard, the shortest code wins, regardless of language. That's where languages like GolfScript and FlogScript (or Ruby and Perl, for "real" languages) really shine. – Chris Jester-Young Mar 17 '10 at 23:29
  • 1
    @earlz, I'd be interested in any references you have that support your view – gnibbler Mar 18 '10 at 0:30
  • 1
    @earlz: Sure, the essence of code golf depends on one's viewpoints and can encompass many factors, and for many people (including myself), it can be about the most clever way to make code short ... but that's not objectively measurable. If you're going to pick a winner that people can agree on, there has to be an objective standard. Character count is the most obvious such measure. Otherwise, it should be clear what standard is being used, and labeling something as code golf when it's ultimately to be subjectively determined is very misleading. – KirarinSnow Mar 18 '10 at 0:43

I wrote a proposal for a dedicated golfing site, which in theory, if all the high-ranking users are real golfers, should eliminate that sort of problem.

However, with the situation here and now, perhaps the best way to deal with it is to ensure that "shortest code" appears in the first line of any description of a code golf, and strip off the [code-golf] tag (and change the post title) if that line fails to appear.

In my humble opinion, anyway. :-)

  • Wait, you mean like codegolf.com? – dmckee Mar 17 '10 at 22:22
  • 1
    @dmckee: Like codegolf.com, but with SO-style up/downvoting, user-submittable questions (think anarchy golf), and with discussions. – Chris Jester-Young Mar 17 '10 at 22:30
  • @dmckee: Lbh unir gb haqrefgnaq, zhpu bs zl erc tnva ba gur znva FB fvgr jnf guebhtu zl "Fgnpx biresybj pbqr tbys" dhrfgvba (juvpu V sbhtug gb xrrc bhg bs PJ fgnghf sbe nf ybat nf cbffvoyr), fb V svaq nal rkphfr V pna gb znxr n PJ-serr tbysvat fvgr, fb crbcyr yvxr zr, Whyvrg, naq tavooyre pna (yrtvgvzngryl) ercjuber jvgu vg. :-P – Chris Jester-Young Mar 17 '10 at 22:33
  • @Chris: NPX. Lbh'q or jrypbzr gb vg. – dmckee Mar 17 '10 at 23:04
  • @Chris, @dmckee, In the mean time I think the best thing to do is to comment and vote to close if it is tagged code-golf but doesn't mention "Shortest Code" as a requirement in the body. We can dream about the dedicated golfing/fun site – gnibbler Mar 19 '10 at 7:49
  • @gnibbler: I understand your desire to avoid tag editing wars (as you mentioned on IRC), but the downside is that close votes are not retractable, so if the OP corrects the question, you don't have a way to signal approval. Maybe retractable close votes should be the next feature to ask for. :-P – Chris Jester-Young Mar 19 '10 at 13:25
  • @Chris, good point sigh hence the need for discussion – gnibbler Mar 19 '10 at 20:00
  • 1
    Luckily, we now do have a Code Golf site (in which all participants of this comment thread are mods :-P), and you now can indeed retract close votes. Yay for progress! :-D – Chris Jester-Young Jul 3 '14 at 18:59

As I've stated elsewhere, I believe code-golf tagged questions are within the spirit and scope of SO.

With that being said,

  • Cool or clever code can't be objectively measured or assessed, and therefore such criteria in code-golf questions will lead to complaints and displeasure.
  • Dedicated code golfing sites (golf.shinh.org, codegolf.com, spoj.pl and others) agree, as a majority, in adopting shortest code as the criterion for "winning".
  • There are already some generally accepted guidelines for code golf questions in SO, as seen here. Other issues, such as excluding certain languages or library usage, etc. can be reasonably defined in each question (I assume we're all mature enough to reach a consensus on such issues, in favour of the "competition" and not our favourite one-character-does-all solutions).
  • In the majority of cases, source code is a more accurate measure over machine code, because machine code depends heavily on the compiler, toolchain etc. Of course, machine code may be hand-written, but then other issues arise; such code is machine dependent and one could invent their own machine language, similarly to what's already being done with 1 character answers. The first time was entertaining, the hundredth not so much. This can be covered by limiting answers to a specified set of languages (white-listing or black-listing, whatever works best for each question).

For all those reasons and their implications, I think we should limit ourselves to shortest (source) code as the most objective and practical measure of success in code-golf tagged questions.

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