Questions tagged [code-golf]
Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
3,998
questions
48
votes
14
answers
17k
views
Tips for golfing in 05AB1E
Do you have any tips for code-golfing in 05AB1E, a golfing language created by Adnan?
Your tips should be at least somewhat specific to 05AB1E.
Please post one tip per answer.
331
votes
179
answers
144k
views
Tips for golfing in Python
What general tips do you have for golfing in Python? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Python (e.g. "remove comments" is ...
88
votes
58
answers
17k
views
Tips for golfing in Haskell
What general tips do you have for golfing in Haskell? I am looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Haskell. Please post only one ...
106
votes
39
answers
28k
views
Tips for golfing in Java
Are there any useful shortcuts that can be used in Java?
As shown below, import already adds at least 17 characters to a program.
...
103
votes
44
answers
13k
views
Tips for golfing in <all languages>
The aim of this post is to gather all the golfing tips that can be easily applied to <all languages> rather than a specific one.
Only post answers that its ...
523
votes
986
answers
195k
views
"Hello, World!"
So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most ...
244
votes
456
answers
65k
views
Golf you a quine for great good!
Using your language of choice, golf a quine.
A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.
No cheating -- that means ...
167
votes
65
answers
41k
views
Tips for golfing in C
What general tips do you have for golfing in C? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C (e.g. "remove comments" is not an ...
17
votes
14
answers
3k
views
I want 8 bits for every character!
This is the reverse of this challenge.
Given an encoded list of codepoints and the characters used to encode it, you need to decompress it to its original string.
For example, given the encoded list <...
173
votes
98
answers
69k
views
Tips for golfing in JavaScript
What general tips do you have for golfing in JavaScript? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to JavaScript (e.g. "remove ...
53
votes
51
answers
8k
views
Tips for golfing in PowerShell
What general tips do you have for golfing in Windows PowerShell? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to PowerShell (e.g. "...
76
votes
59
answers
20k
views
Tips for code-golfing in C#
What general tips do you have for golfing in C#? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C# (e.g. "remove comments" is not an ...
71
votes
23
answers
8k
views
Tips for golfing in R
I'm looking for tips for golfing in the R statistical language. R is perhaps an unconventional choice for Golf. However, it does certain things very compactly (sequences, randomness, vectors, and ...
236
votes
369
answers
66k
views
Is this number a prime?
Believe it or not, we do not yet have a code golf challenge for a simple primality test. While it may not be the most interesting challenge, particularly for "usual" languages, it can be nontrivial in ...
81
votes
53
answers
36k
views
Tips for golfing in Ruby
What general tips can you give for golfing in Ruby?
I'm looking for ideas that can be applied to code golf problems in general that are specific to Ruby. (For example, "Remove comments" would not be ...