Code golf


Code golf
An example round of code golf running on 4clojure.com, showing the problem expressed as a series of unit tests, special requirements for the round's problem, and a results graph (the "league") with a personal score.

Code golf is a type of computer programming competition in which participants strive to achieve the shortest possible code that implements a certain algorithm. Such tournaments may also be named with the programming language used (for example Perl golf).

Contents

History

Whilst the term was apparently first used in 1999 with Perl,[1] and later popularised through the use of Perl to write a program that performed RSA encryption,[2] similar informal competition was known to have been popular with earlier APL hackers and probably others. Today the term has grown to be applied to a wide variety of languages.

Etymology

The term is derived from the similarity of its scoring system with that of conventional golf - ie: participants seek to achieve the lowest possible score, rather than the highest as is the standard in most sports' scoring systems.

Types of code golf

Some code golf questions, such as those posed on general programming sites, may not require implementation in a specific programming language. However, this is limits the style of problems that it is possible for the problem designers to pose (for example, by limiting the use of certain language features). In addition, the creation of such 'open' questions has resulted in the design of code golf specific programming language dialects such as REBMU (a dialect of REBOL). Both online and live competitions may also include time limits.

Tournaments by language

See also

External links

References

  1. ^ Greg Bacon (1999-05-28). "Re: Incrementing a value in a slice". comp.lang.perl.misc. (Web link). Retrieved 2011-07-12. 
  2. ^ Back, Adam. "RSA in 5 lines of perl". http://www.cypherspace.org/rsa/pureperl.html. Retrieved 2011-01-10. 
  3. ^ ["http://www.4clojure.com" "4clojure League"]. "http://www.4clojure.com". Retrieved 2011-07-24. "While the primary purpose of 4clojure.com is to teach Clojure "by doing", you may also choose to compete for the shortest solution. This is affectionately known as code golf: the lower your score the better, get it? If you choose to participate, we'll score your correct solutions based on the number of non-whitespace characters (and some more metrics in the future). We'll also provide a chart showing how you stack up compared to everyone else on the site." 
  4. ^ ["https://github.com/kevinlawler/kona/wiki/Project-Euler-Code-Golf" "Project Euler Code Golf"]. "https://github.com/kevinlawler/kona/wiki/Project-Euler-Code-Golf".