What does "Code Golf" mean?
Code golf, (Or Codegolf) as the name suggests, is the art of making programs that are as short as possible that complete a task.
What is "Programming Puzzles & Code Golf"?
PPCG is a Community in which people ask Questions (Challenges), and others answer them. The challenges are usually code-golf (See above), although can sometimes be fastest-code, king-of-the-hill and others. All challenges must have an Objective Winning Condition, which means there must be a rule that can determine which of two answers is better. In Code Golf, this is "the shortest code wins".
What makes a challenge, what makes an answer?
A challenge is something that can be solved by a program, this usually means taking certain inputs and providing certain outputs, with some criteria to show how some solutions are objectively better than others. (This usually has nothing to do with what's good practice, that's Code Review's job. :p)
Answers are just solutions to the task a challenge provides, these must contain:
- The language the solution was written in
- The length of the solution in bytes
- The solution itself
The way these solutions take input is usually defined by Our I/O Defaults unless otherwise specified in the challenge, and we also have a list of Forbidden Loopholes to prevent "cheap" solutions, like loading and executing the solution from a webpage.
Why is everything so short?
Since this community's creation, users have been trying to outdo eachother, both in code length of the same langauge, and in choice of language.
As you can only go so far with languages like C, Java, Python, or Perl, users (and those from outside the community) create their own esoteric "Golfing Languages". These languages put understandable code to the side, and instead implement tricks to help their code be as short as possible.
GolfScript is one of the earliest languages to do this (And gained a lot of negative heat in its day because of it) and was a Stack Based language where almost every command was a single ASCII character. This means that reversing a string goes from
string.reverse(input) to just
Now, languages like Jelly have their own Code Page so they can make the most out of each byte and use other tricks to make it even more ridiculously short.
Don't be intimidated by this!
Although users like to try to outgolf each other at the language level, (I myself am competing with RProgN2), this is all in good fun, and competition is really intra-language, rather than inter-language. Feel free try to take on challenges in any language, and try to do better than anyone else who's already done it, or do it first to set the record. It is, of course, all in good fun.
Check out our FAQ for more info!