Skip to main content

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.

Filter by
Sorted by
Tagged with
24 votes
27 answers
2k views

Tips for golfing in sed

What general tips do you have for golfing in sed? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to sed (e.g. "remove comments" is not ...
6 votes
1 answer
444 views

Further golfing this C# code from Scramble words while preserving their outlines

I'll start off by saying I checked and checked again that this question should be on topic. I will also clearly state that this is a tips question about further golfing a certain set of code not a ...
167 votes
66 answers
40k 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 ...
63 votes
31 answers
20k 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 ...
25 votes
12 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 ...
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. "...
41 votes
26 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 ...
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 ...
0 votes
1 answer
262 views

How can I reduce the characters in the following python code? [closed]

The following code is 47 characters. print(("Ekki v","V")["COV"in input()]+"eikur!") How can it be reduced to 46 or less? I ...
17 votes
9 answers
1k views

Tips for golfing in ><> (Fish)

Since I've been seeing more ><> submissions floating around lately, I thought it might be a good idea to have a tips page. Please stick to one tip per post, unless they are closely related. ...
2 votes
0 answers
89 views

Tips for golfing in Emmental

What general tips do you have for golfing in Emmental? It is a self-modifying language defined by a meta-circular interpreter, so I wonder if there are tips for golfing for this esoteric programming ...
7 votes
2 answers
181 views

Tips for golfing in 𝘈𝘤𝘤\$\it{!!}\$

What general tips do you have for golfing in Acc!!? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Acc!! (e.g. "remove comments&...
71 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 ...
21 votes
34 answers
3k views

Tips for golfing in VBA

Similar to this, this, and this question... What general tips do you have for golfing in VBA? I'm looking for ideas that can be applied to code golf problems in ...
329 votes
179 answers
143k 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 ...
0 votes
2 answers
207 views

Tips for golfing in Wren

Wren is a small, fast, class-based concurrent scripting language. Does anyone have any tips for this language? Please make sure to post 1 tip per answer, and don't post answers like "remove ...
5 votes
3 answers
871 views

Tips for shortening this type-safe addition in JavaScript

Consider: c=(a,b)=>(+a||0)+(+b||0) Yes, it is not good to solve it like that. But I want to shorten it even more. If a is a ...
6 votes
2 answers
522 views

Situations when recursion helps [closed]

Recursion is actually quite powerful, sometimes its doesn't look like that child problem of itself exist, but recursion is just helpful. One case per answer.
0 votes
0 answers
137 views

Shortest Float32Array to Int32Array conversion for audio processing

I'm currently converting a Float32Array to an Int32Array for input to a real-time audio raw PCM to MP3 recording application. <...
53 votes
44 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 ...
4 votes
0 answers
112 views

Electra "Hello World!" [duplicate]

This will be a bit of a different challenge. Back in 2023, I developed a 2D esolang called Electra, and looking back at my hello world program, (which is 582 bytes by the way) I see a lot of room for ...
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 ...
29 votes
15 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 ...
52 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 ...
-2 votes
1 answer
195 views

Solving Reverse Polish Notation with GolfScript and Eval Function

I am exploring a unique approach to the classic problem of Reverse Polish Notation on code.golf. Unlike the conventional solutions, my focus lies on leveraging the ...
7 votes
3 answers
431 views

Tips for golfing in Uiua

What general tips do you have for golfing in Uiua? I'm looking for ideas that can be applied to code golf problems in general that are specific to Uiua. (e.g. "remove comments" would not be ...
53 votes
29 answers
15k 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 ...
28 votes
18 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 ...
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. ...
0 votes
0 answers
233 views

How to efficiently count all powers of 2 in a given set of numbers in vb.net?

Every integer can be expressed in powers of 2. You know this as the binary system Assume you are given a set of k numbers (...
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 ...
0 votes
0 answers
89 views

Shortest way to print the first 20 numbers in the fibbonacci sequence with python3 [duplicate]

I was wondering if it was possible to make this code even shorter than it already was. f=lambda x:f(x-1)+f(x-2) if x>1 else 1 [print(f(i))for i in range(20)] ...
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 ...
8 votes
3 answers
2k views

Convert a string representation of a number to int[] in C#

What is the shortest C# statement that will convert a string representation of a number to an int[] that contains each digit? ...
6 votes
4 answers
1k views

Shortest C code to display argv in-order

I recently tried to produce the shortest C code possible to display all its command line arguments (which are stored in argv). I ended with a relatively small piece of code, and I was wondering if ...
25 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 ...
8 votes
1 answer
316 views

Tips for Golfing in Vyxal 3

The reason for this question is because I made a deadlineless bounty and I need a tips question to link in the bounty Vyxal 3 is the third major version of the Vyxal golfing language. As it is ...
11 votes
6 answers
572 views

Tips for golfing in Retina

What general tips do you have for golfing in Retina? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Retina (e.g. "remove comments" is ...
18 votes
16 answers
1k views

Tips for Golfing in Vyxal

Vyxal is a golfing language that has 500+ different commands (achieved through overloads), and is a known beater of Jelly, 05AB1E and most golfing languages. Henceforth, it seems like a good idea to ...
69 votes
43 answers
12k 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 ...
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 ...
6 votes
0 answers
266 views

Shortest CSS selector to select ALL html elements, without using asterisk *

What is the shortest selector (by character count) to select ALL html elements on a web page, without using asterisk (*)? Some examples are the following: ...
12 votes
7 answers
4k views

How can I shorten a C code that repeatedly outputs a number?

I wrote a code that separates the numbers from 1 to 9999 by comma void p(n){printf("%d,",n);if(n<9999){p(n+1);}}main(){p(1);} Is there a way to make ...
10 votes
12 answers
2k views

Tips for golfing in TypeScript's type system

What general tips do you have for golfing in TypeScript's type system? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to TypeScript's ...
22 votes
10 answers
1k views

Tips for golfing in Prolog

What general tips do you have for golfing in Prolog? I am looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Prolog (e.g. one letter ...
2 votes
2 answers
235 views

Binary expansion and partition numbers [closed]

Not sure if it's correct to ask such a question on this site, but let's try. Let a(n) be a sequence of positive integer such that a(1) = 1. To reproduce the sequence a(n) through itself, use the ...
17 votes
4 answers
7k views

Is there a shorter way to get user input in python?

This is not a challenge. I'm wondering if it's at all possible to get user input into two separate variables in python (2 or 3) with less than 19 bytes. These are all the shortest I can get: ...
6 votes
2 answers
281 views

Tips for radiation hardening

The aim of this post is to gather all the tips that can often be applied to radiation-hardening challenges. Please only post answers which can apply to a large number of languages, and one tip per ...
-3 votes
1 answer
104 views

PHP+C polyglot solution to mixed types

Some built-in functions in PHP return mixed types, like file_get_contents that returns both string or ...
5 votes
1 answer
311 views

Tips for Golfing the Lambda Calculus & Friends

This includes tips for all related derivatives, as coding in these langs often primarily consists of writing the function in the lambda calculus and then compiling it down at the end. Among others, ...

1
2 3 4 5
8