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
306
votes
161answers
113k 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 ...
6
votes
5answers
102 views

Tips for golfing in Lexurgy

What general tips do you have for golfing in Lexurgy? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Lexurgy (e.g. "remove ...
41
votes
14answers
13k 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.
29
votes
11answers
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 ...
-2
votes
0answers
101 views

Tips for golfing in !@#$%^&*()_+

What general tips do you have for golfing in !@#$%^&*()_+? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to !@#$%^&*()_+ (e.g. &...
17
votes
12answers
867 views

Tips for golfing in Charcoal

Charcoal is a language created by ASCII-only and DLosc that specialises in ASCII art challenges. What tips do you have for golfing in Charcoal? Obviously I am looking for tips related specifically to ...
-1
votes
0answers
124 views

Tips for golfing in chicken

What general tips do you have for golfing in Chicken? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Chicken (e.g. "remove ...
19
votes
10answers
1k views

Tips for Code Golfing in Desmos

Desmos is mainly used as an online graphing calculator, but its graphical and mathematical functionalities can also be applied in certain coding challenges. I know not that many people use Desmos on ...
-3
votes
0answers
64 views

Is there a way to replace multiple "replace" functions Python3 [duplicate]

For a code-golf challenge, i had to use multiple text.replace(" ","") inside my code. Is there a way to use something like: ...
14
votes
18answers
502 views

Tips for golfing in Factor

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

Tips for golfing in PARI/GP

PARI/GP is a free computer algebra system. It is designed for (algebraic) number theory, not golfing, but that's part of the attraction. Unsurprisingly, it fares best at mathematical tasks; its ...
7
votes
4answers
652 views

How can I golf this code to count all perfect squares below 100?

I'm trying to strip down my python code to be as few lines as possible. The task: count how many square numbers are below 100. Here's my code so far: ...
3
votes
4answers
856 views

JavaScript: Tricks to shorten onkeydown, setInterval etc

Are there any tricks to shorten defined function names like setInterval, onkeydown, onkeyup, createLinearGradient or even return? When using it more than once it's nice to put it as a string into a ...
18
votes
4answers
865 views

Tuple addition in pointfree

What is the shortest way we can express the function f(a,b)(c,d)=(a+c,b+d) in point-free notation? pointfree.io gives us ...
10
votes
2answers
710 views

Can I shorten this Python code for simulating a car driving around

I am trying to write a solution to the following problem using as few characters as possible (to meme my friend and introduce him to golfing). Can any improvements be done to my code? So the problem ...
56
votes
28answers
16k 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 ...
2
votes
3answers
363 views

Tips for golfing in Visual Basic .NET

This page is not for Visual Basic Tips Visual Basic .NET (VB.NET) is an multi-paradigm dialect of basic that was developed and released by Microsoft in 2002 as a replacement for Visual Basic. The ...
2
votes
2answers
102 views

Tips for golfing in VB.net [duplicate]

Any general tips for golfing in VB.net? This, similar to Pascal, is a very rarely used language, thus having very few resources online Visual Basic.NET (VB.NET) is a multi-paradigm, managed, type-safe,...
11
votes
4answers
493 views

Tips for golfing in Add++

Add++ is the Language of the Month for January 2022, and so I'm asking for tips for golfing in it. Please stick to tips specific to Add++, and avoid general tips such as "remove whitespace" ...
3
votes
0answers
76 views

Tips for golfing in Objective C

Surprisingly, I do not think this question has been asked before Although on codingame.com, Objective C and C are two of the best golfing languages there, so I would like to know some of the best ...
3
votes
1answer
95 views

Tips for golfing in Pascal

What general tips do you have for golfing code in Pascal? I know this is a tricky language very few people use this but I would like to know any tips from the professionals out there :) I'm looking ...
156
votes
57answers
32k 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 ...
37
votes
19answers
3k 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 ...
11
votes
4answers
492 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 ...
7
votes
2answers
128 views

In as few bytes as possible in t-sql, return 100 rows containing the phrase 'Have a great Christmas'

In as few bytes as possible in t-sql, return 100 rows containing the phrase 'Have a great Christmas' 92 (I think) to beat :D ...
43
votes
40answers
6k 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 ...
9
votes
2answers
196 views

Tips for golfing in BQN

What general tips do you have for golfing in BQN? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to BQN (e.g. "remove comments"...
13
votes
12answers
600 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 ...
5
votes
8answers
1k 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 ...
13
votes
4answers
539 views

Tips for golfing with numpy, scipy, or pylab

There's already a comprehensive list of tips for python here, so what I'm asking for are tips that specifically apply to using the numpy, ...
6
votes
0answers
237 views

Tips for golfing in Chef

What general tips do you have for golfing in Chef? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Chef (e.g. "remove unnecessary ...
4
votes
3answers
470 views
19
votes
1answer
411 views

How to solve the LCM in 50 bytes of Python

I've recently stumbled upon a Russian site called acmp.ru, in which one of the tasks, HOK, asks us to find the LCM of two positive integers. The full statement, translated to English is as follows: ...
8
votes
4answers
2k views

How to shorten the python code?

I'm writing a program that takes a number from input (call it x), loops from 0 to (x - 1) (let's call our iterator y) and prints \$y^x+x\$ for each y. After the loop, it then prints "SUM: N" ...
95
votes
41answers
10k 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 ...
2
votes
2answers
101 views

Tips for parsing Standard Input in JavaScript

I've been doing quite a few code golf recently and I realised that a lot of times, I have to do something involving list. Most of the times lists are space-separated or comma-separated values in the ...
61
votes
41answers
9k 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 ...
159
votes
91answers
57k 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 ...
5
votes
2answers
351 views

Pushing the limits to make a piece of code solving the K-Goodness String problem shorter

I am trying to push my limits of making a python code as short as possible. I left the readability part way behind. I was attempting the K-Goodness String problem from Round A of Google Kick Start ...
-1
votes
1answer
190 views

Shortest way to convert a float to an int [closed]

I'm not really sure if this is the right place to ask this. Now, I know I can convert a float to an int with int, but is there some shorter way?
73
votes
53answers
27k 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 ...
3
votes
2answers
405 views

Remove duplicates from list and order it by count? (python 3)

How do I remove all duplicates from list and order it based on count? ...
10
votes
2answers
323 views

Branchless (MIPS) assembly code for median of 3

I was trying to write a short MIPS32 code for computing the median of three registers. The rules: Assume that some values are pre-loaded into $t0, ...
41
votes
17answers
5k 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-...
83
votes
55answers
14k 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 ...
16
votes
11answers
453 views

Tips for golfing in INTERCAL

What general tips do you have for golfing in INTERCAL? I'm looking for ideas which can be applied to code golf challenges and are also at least somewhat specific to INTERCAL (i.e. "remove comments" is ...
7
votes
3answers
380 views

Tips for golfing in Lean

Lean is a theorem prover and programming language. It's also as of writing the Language of the Month! What tips do people have for golfing in Lean? As always, tips should be specific to to Lean (e.g....
6
votes
1answer
262 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 ...
8
votes
7answers
262 views

Tips for golfing in jq

Since jq is the Language Of The Month for September 2021, what general tips do you have for golfing in jq? I'm looking for ideas which can be applied to code-golf problems and which are also at least ...
41
votes
31answers
5k 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 ...

1
2 3 4 5
7