Questions tagged [tips]
For questions asking for tips on golfing in a specific language, doing well in certain challenge tag, or improving a particular piece of code.
370
questions
326
votes
177
answers
139k
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 ...
173
votes
97
answers
67k
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 ...
162
votes
61
answers
39k
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 ...
109
votes
43
answers
18k
views
Tips for Golfing in ECMAScript 6 and above
This is similar to other "Tips for golfing in <...>" but specifically targeting the newer features in JavaScript brought up in ECMAScript 6 and above.
JavaScript inherently is a very verbose ...
106
votes
39
answers
27k
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.
...
102
votes
44
answers
12k
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 ...
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 ...
86
votes
11
answers
16k
views
How on earth did llhuii output the Evil Numbers in 42 bytes of Python?
This is a tips question for golfing in Python concerning the Evil Numbers question on Anarchy Golf.
An number is evil if its binary expansion has an even number of 1's. The challenge is to print the ...
78
votes
53
answers
35k
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 ...
75
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 ...
70
votes
43
answers
11k
views
Tips for golfing in Bash
What general tips do you have for golfing in Bash? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Bash (e.g. "remove comments" is not ...
70
votes
23
answers
7k
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 ...
62
votes
30
answers
19k
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 ...
58
votes
25
answers
16k
views
Tips for golfing in Jelly
Jelly is a tacit, golf-oriented programming language by our very own Dennis. It’s popping up in answers here more and more often, beating other golf-y languages like Pyth and CJam, both by using its ...
53
votes
26
answers
14k
views
Tips for golfing in Perl?
What general tips do you have for golfing in Perl? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Perl (e.g. "remove comments" is not ...
52
votes
43
answers
7k
views
Tips for golfing in Mathematica
What general tips do you have for golfing in Mathematica? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Mathematica (e.g. "remove ...
51
votes
16
answers
4k
views
Tips for creating polyglots
A polyglot is a program that can be run in 2 or more different programming languages.
What general tips do you have for making polyglots, or choosing languages that are easy to write polyglots for a ...
51
votes
17
answers
10k
views
Tips for Regex Golf
Similar to our threads for language-specific golfing tips: what are general tricks to shorten regular expressions?
I can see three uses of regex when it comes to golfing: classic regex golf ("here ...
50
votes
49
answers
7k
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. "...
49
votes
35
answers
8k
views
Tips for golfing in x86/x64 machine code
I noticed that there's no such question, so here it is:
Do you have general tips for golfing in x86/x64 machine code? If the tip only applies to a certain environment or calling convention, please ...
49
votes
24
answers
8k
views
Tips for golfing in Pyth
Pyth is a Python-inspired procedural programming language, created by PPCG user isaacg.
What general tips do you have for golfing in Pyth? I'm looking for ideas that can be applied to code golf ...
49
votes
19
answers
3k
views
Tips for golfing in The Shakespeare Programming Language
What general tips do you have for golfing in The Shakespeare Programming Language? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to SPL ...
48
votes
14
answers
16k
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.
46
votes
15
answers
3k
views
Tips for Creating/Maintaining a Golfing Language
Creating a golfing language can be hard. Let's help budding golfing language creators out and provide some helpful tips on how to create one.
I'm looking for tips on:
The design process
...
44
votes
34
answers
4k
views
Tips for golfing in CJam
CJam is a GolfScript-inspired stack-based golfing language, created by PPCG user aditsu.
So, in the vein of other language-specific tips questions:
What general tips do you have for golfing in CJam? ...
43
votes
18
answers
6k
views
Tips for golfing in GolfScript
What, this post doesn't exist yet?
Of course, GolfScript is made for golfing, so you might think that no specific tips are really needed. But to make full use of GolfScript's features, you need to ...
43
votes
18
answers
5k
views
Tips for golfing in APL
I started one code golf challenge recently and it seems like the winner is GolfScript (surprise, surprise!). What's interesting is that there was another very strong competitor that had all chances to ...
42
votes
17
answers
6k
views
Tips for restricted source in Python
Just like code-golf, restricted-source pushes one to exploit quirks and hidden features of the Python language. We already have a place to collect all these tips for code-golf, those for restricted-...
41
votes
22
answers
4k
views
Tips for golfing in Rust
While Rust is very, very rarely competitive in code golfing competitions (Java is often shorter), it can still be fun to golf in. What are some tricks for making Rust code shorter?
Please post only ...
41
votes
40
answers
11k
views
Tips for golfing in PHP
What general tips do you have for golfing in PHP? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to PHP (e.g. "remove comments" is not ...
39
votes
15
answers
4k
views
Tips for golfing in J
GolfScript gets its own way far too often and I feel that a repository of handy hints for golfing in J might help in the fight against the evil empire. What tips do you have for making this already ...
36
votes
13
answers
3k
views
Tips for golfing in vim
I've recently realized how vim works great for golfing, especially for kolmogorov-complexity. Also, according to meta vim is a perfectly acceptable 'programming language' at least, for the scope of ...
34
votes
7
answers
58k
views
Generating the alphabet in JavaScript
I'm pretty sure there's not a better way to do this but figured it couldn't hurt to ask.
I'm tired of typing out a='abcdefghijklmnopqrstuvwxyz'.
Cool languages ...
33
votes
7
answers
3k
views
Tips for writing quines
A quine is a program that produces output that's identical to the program's source code. On this website, we generally only care about proper quines (at the time of writing, the current definition is "...
33
votes
6
answers
16k
views
Python workarounds for assignment in lambda
This is a tips question for golfing in Python.
In Python golfing, it's common for a submission to be a function defined as a lambda. For example,
...
32
votes
14
answers
3k
views
Tips for golfing in TeX/LaTeX
What tips do people have for golfing in TeX/LaTeX? Please post one tip per answer, each at least somewhat specific to TeX/LaTeX.
Context: I noticed this answer and that there is no tips question for ...
32
votes
6
answers
12k
views
Choosing Languages for Golfing [closed]
What are some tips for choosing the right language to golf?
What factors affect the language to be chosen?
Here are some example problem types:
Problems that require I/O solution, either console or ...
31
votes
10
answers
2k
views
Tips for golfing in Excel?
It's strange that I haven't seen this, as Excel seems to be a valid language for code golfing (despite its 'compiler' not being free).
Excel is somewhat of a wildcard in golfing, being good at ...
29
votes
8
answers
3k
views
Tips for golfing in Julia
What general tips do you have for golfing in Julia? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Julia (e.g. "remove comments" is ...
28
votes
16
answers
3k
views
Tips for golfing in Scala
What general tips do you have for golfing in Scala? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Scala (e.g. "remove comments" is ...
28
votes
12
answers
2k
views
Tips for golfing in TI-BASIC
What general tips do you have for golfing in TI-BASIC for the TI-83/84+ series calculators? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat ...
28
votes
11
answers
3k
views
Tips for golfing in Lua
What general tips do you have for golfing in Lua? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Lua (e.g. "remove comments" is not ...
28
votes
13
answers
2k
views
Tips for golfing in Swift
What are some tips for code-golfing in Swift? Its focus on safety seems to make it difficult to golf in, but that makes little tips and even more useful. Are there any features in Swift that may help ...
27
votes
16
answers
3k
views
Tips for Golfing in Go
What general tips do you have for golfing in Go? I'm new to Code Golfing and looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Go.
Please ...
27
votes
5
answers
3k
views
Tips for golfing in brainfuck
What general tips do you have for golfing in brainfuck? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to brainfuck (e.g. "remove ...
27
votes
7
answers
12k
views
How do I alias member functions in Python?
In Python, one can save bytes by aliasing functions that are used repeatedly. For example:
r=range
a=r(100)
b=r(200)
c=r(300)
However, when the functions are ...
25
votes
9
answers
2k
views
Tips for Golfing in Brain-Flak
Brain-flak is a stack-based turing-tarpit language, written collaboratively between me, DJMcMayhem, and 1000000000.
Some users are very experienced in the mysterious ways of Brain-Flak. So I thought ...
25
votes
11
answers
2k
views
Tips for golfing in Kotlin
Given Google's recent announcement of official Kotlin support for Android development, I thought it might be timely to poll the community for some awesome golfing tips for this relatively new JVM ...
24
votes
13
answers
2k
views
Tips for golfing in F#
What general tips do you have for golfing in F#? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to F# (e.g. "remove comments" is not an ...
24
votes
9
answers
3k
views
How can Pyth be improved? [closed]
Pyth is in ongoing development, meaning that new features are being added all the time.
I want to make Pyth a better langauge, so I'd like to know what features people are looking for.
This is the ...