What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 134 Stack Exchange communities.

See http://codegolf.stackexchange.com

It seems that someone gives us a problem to solve, tags the question and the winner is whoever completes the solution in the fewest characters. I haven't found a reference for what it is, so lets discuss its purpose here.

EDIT: OK, we've explained what it is, but why stage a competition to see who can use the least number of characters? It's an interesting contest (and that may be the point and I'm looking too deeply) but it doesn't seem to have any other reason. It is terrible to read; I think we could have more interesting contests to see who could make the fastest or most flexible or otherwise "best" solution.

share|improve this question

closed as off-topic by Undo the Snowman, Martijn Pieters, Monica Cellio, Emrakul, Azik May 15 at 5:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question pertains only to a specific site in the Stack Exchange Network. Questions on Meta Stack Exchange should pertain to our network or software that drives it as a whole, within the guidelines defined in the help center. You should ask this question on the meta site where your concern originated." – Undo the Snowman, Martijn Pieters, Monica Cellio, Emrakul, Azik
If this question can be reworded to fit the rules in the help center, please edit the question.

4  
Justifying a game is like explaining a joke is like dissecting a butterfly. –  Benjol Feb 8 '10 at 9:06
1  
What is the purpose of sudoku and crosswords? –  gnibbler Mar 19 '10 at 20:47
    
@gnibbler to be able to show others how smart I am. –  Itay Moav -Malimovka Jun 20 '10 at 0:11

10 Answers 10

up vote 17 down vote accepted

Like in golf where the low score wins, the fewest amount of characters "wins". While certainly the best solution in every case is not necessarily the solution that has the fewest characters or fewest lines of code, it can be a fun way to exercise your programming muscles. There is even a codegolf.com.

share|improve this answer
2  
Yes, “fewest (key)strokes wins” is exactly what I had in mind when I coined the phrase‌​. –  Greg Bacon Aug 5 '10 at 20:53

Try to solve the problem using the fewest possible characters of source code.

It's relatively well-known in Perl circles, since Perl's flexibility and terseness make possible very brief solutions to many problems. In fact, some sources say that code golf originated as "Perl golf". It's no coincidence that in language-agnostic code golf challenges, a Perl solution is usually the winner.

When the winner uses a language other than Perl, that is truly an accomplishment, not only because Perl is naturally suited to this sort of challenge, but because Perl programmers are largely well-acquainted with the game and know the tricks and techniques to golf effectively in their language of choice.

share|improve this answer
3  
I do not think that winning solutions in GolfScript are "truly an accomplishment". :-P –  Chris Jester-Young Oct 13 '09 at 17:14
    
Well, it's at least "kinda" an accomplishment. It's not like you don't have to think to write a GolfScript solution. ;) –  ベレアー アダム Dec 1 '09 at 21:04
    
Writing or understanding GolfScript appears to be less of a challenge than doing the same with J, though. At least in my experience. –  Joey Jun 9 '10 at 22:08

I like the atmosphere of code-golf on SO, The other sites mentioned all have us golf in secret and sometimes never reveal the secret source.

As someone who golfs regularly on SO in 6 or so languages, I find I am sometimes learning useful new things about those languages due to the openness and collaboration that is unique to SO code-golf.

share|improve this answer
    
+1. Heck, I learned many things about a language I'm now using on a daily basis by golfing Project Euler problems in it. It certainly is a great way of finding and trying out even the most obscure language features – not all of them lead to shorter results in all circumstances but you still know tricks you'd otherwise probably never encountered. –  Joey Jun 9 '10 at 22:11

a complete waste of time and pixels - on SO [please people, leave this stuff on codegolf.com where it belongs; leave SO for useful questions]

share|improve this answer
7  
@Steven, it can be useful for sharpening skills, personally I prefer these questions to "what is your favorite IDE color scheme" –  waffles Sep 7 '09 at 23:07
2  
While I agree that it is more useful than "what is your favorite IDE color scheme" I do not think that makes it useful for the site. If you want to sharpen your skills, go find someone's intractable problem and help them solve it. –  AnonJr Sep 7 '09 at 23:19
7  
why whine about it? It would take fewer keystrokes to add "code-golf" to you Ignored tags list than it did to write your mini-rant. –  Argalatyr Sep 7 '09 at 23:21
3  
@[Sam Saffron]: "what is your favorite IDE color scheme" I can close as not-programming-related - and I would; code-golf is technically a programming question so I can't in good faith vote to close it, but it is non-productive noise. @[Argalatry]: i forgot about ignored tags, i'll do that right away - but that does not alter the navel-gazing, bit-wasting, pixel-churning, pocket-pool nature of code-golf questions on SO :-P –  Steven A. Lowe Sep 8 '09 at 1:33
    
@[Argalatyr]: ignored meta-code-golf as well, thanks again for the reminder! –  Steven A. Lowe Sep 8 '09 at 1:35
8  
"A waste of pixels". Never heard that one before. Are we running out? ;) –  Rex M Sep 8 '09 at 2:53

Code golf is for those bored of helping people solve real problems, but don't want to leave the site.

As per my comment, while I agree that it is more useful than some of the questions floated (the aforementioned "what is your favorite IDE color scheme" comes to mind) I do not think that makes it useful for the site.

If you want to sharpen your skills, go find someone's intractable problem and help them solve it.

share|improve this answer
2  
This looks very much like a comment, not an answer to the question. –  Argalatyr Sep 7 '09 at 23:23

http://codegolf.stackexchange.com/ has been in public beta for 11 months.

share|improve this answer

shortest->+1

(12 character response)

share|improve this answer

In the game of golf, the player who completes the course with the fewest club strokes wins. Likewise, code golf is a competition to achieve the specifications in the fewest keystrokes. It's been popularized on SO and other programming fora, as well as in organized competitions.

share|improve this answer
    
Code golf has been around a long time, I first came across it ?10 years ago. –  Richard Oct 2 '09 at 8:31
    
Yes, that's consistent with the link I provided, which was an organized competition 9 years ago. –  Argalatyr Oct 2 '09 at 9:35
    
@Richard: It started way earlier even, with APL. –  Joey Jun 9 '10 at 22:10

It's a puzzle-style problem, which is a classic playground for programmers. A puzzle-style problem relating to programming is like chocolate for your girlfriend...it's not even a question of whether it'll be wanted. :-)

share|improve this answer

I will sometimes answer such questions by defining a program language that generates an executable which implements the questioner's requirements when faced with an empty file as source code, and then claim zero characters.

No-one ever recognises my brilliance.

share|improve this answer
    
They don't even let you define a library function... –  Tom Hawtin - tackline Oct 26 '09 at 1:20
    
i think there's one language with only 3 commands, each 1 letter. One prints nintey nine bottles of beer of the wall, one prints the source code (and another one). Talk about somebody who was addicted to codegolf... –  Gordon Gustafson Oct 26 '09 at 23:41
    
@crazyju: HQ9+. –  Joey Jun 9 '10 at 22:12
    

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