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.
388 questions
1
vote
1
answer
156
views
Tips for making a compiler that generates a golfed program
I would like to create a language that is specifically designed for compiling/translating to another Turing tarpit language. I want to make the program of the target language to be as short as ...
2
votes
1
answer
351
views
Code Golfing in Bash
I'm pretty new to code golfing, but I recently came across a guy on Kattis that consistently has exactly 5 character Bash solutions for some problems. For example, here is a leaderboard showing his 5 ...
8
votes
5
answers
2k
views
Tips for golfing in ☾ (Moon)
What general tips do you have for golfing in ☾ (Moon)? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to ☾ (e.g. "remove ...
7
votes
4
answers
1k
views
Tips for golfing in array languages
We already have a few language-specific tips threads for languages which fall under the array-language umbrella, but there are many golfing tricks which are more or less universal among these ...
7
votes
1
answer
356
views
Tips for golfing in Maple
Maple is designed for mathematical computation, with a focus on symbolic algebra, calculus, and data visualization. I’m experimenting with code golf in Maple and want to make my scripts as concise as ...
4
votes
0
answers
180
views
Tips for golfing in Sidef
Sidef, created by Daniel Șuteu, is designed for expressive, compact code, especially in mathematical domains (e.g., number theory, combinatorics). I’m diving into code golf challenges using Sidef and ...
11
votes
7
answers
3k
views
Tips for golfing in Fortran
Fortran is a compiled imperative language known for its numerical and scientific computing strengths. It blends traditional procedural programming with some modern features like array operations.
What ...
3
votes
1
answer
132
views
Tips for golfing in COBOL
COBOL is a high-level, compiled programming language designed for business applications, readability, and long-term maintainability. It emphasizes verbose syntax, English-like readability, and robust ...
3
votes
5
answers
205
views
Tips for golfing in Bespoke
What are some general tips you have for golfing in Bespoke? I want answers that are specific to Bespoke (e.g. don't just say "remove comments"). One tip per answer.
Esolangs page
...
3
votes
0
answers
203
views
Tips for golfing in Zig
Zig is a low-level, statically typed, and compiled systems programming language designed for safety, performance, and simplicity. It provides direct control over hardware with an emphasis on explicit ...
0
votes
1
answer
330
views
How can I shorten this Python code from 214 bytes to under 200 bytes? [closed]
I have the following Python code, which is 214 bytes long:
...
10
votes
1
answer
1k
views
10
votes
4
answers
908
views
GolfScript many-items rotation
There isn't a builtin in golfscript which lets you rotate a bigger portion of the stack than the three top-most elements.
It should take one number n as argument and rotate the nth value from the top, ...
0
votes
1
answer
402
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 ...
3
votes
0
answers
193
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 ...
8
votes
5
answers
447
views
Tips for golfing in Acc!!
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&...
7
votes
2
answers
596
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.
1
vote
0
answers
274
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.
<...
4
votes
0
answers
125
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 ...
-2
votes
1
answer
284
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 ...
15
votes
9
answers
2k
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 ...
8
votes
4
answers
2k
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 ...
11
votes
1
answer
458
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 ...
6
votes
2
answers
393
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 ...
2
votes
2
answers
281
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 ...
6
votes
2
answers
383
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 ...
-2
votes
1
answer
148
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 ...
1
vote
1
answer
252
views
Shorten this recursive even fibonacci implementation [closed]
I have the following Haskell code to generate the the values of the Fibonacci sequence which are even as an infinite list:
...
2
votes
0
answers
133
views
Tips for golfing in Thue
Anyone got tips for golfing in Thue. One tip per answer, and no tips aplicable to all languages (like remove comments)
4
votes
4
answers
265
views
Tips for golfing in (,) in-paren-comma
What tips do you have for golfing in (,)? I've found that there are so many ways to make code shorter, and I want more ways. I doubt there even are any tips for (,) that are applicable in the majority ...
7
votes
6
answers
317
views
Tips for golfing in Arturo
Arturo is a bytecode-compiled/interpreted, garbage-collected general-purpose language filling a role similar to JavaScript, Python and Ruby. It is centered around the concept of blocks, which hold ...
13
votes
2
answers
1k
views
Can Bitshift Variations in C Minor be compressed down to less than 185 characters?
Bitshift Variations in C Minor by Robert Miles is a Code Golf music piece written in C (with some additional bash commands). It was originally presented in a 2016 Computerphile video Code Golf & ...
-3
votes
1
answer
595
views
What is the ABSOLUTE shortest way to write this code?
So I got kinda bored and was wondering if it was possible to make this code shorter without modifying anything except a file named coin.py...
...
3
votes
6
answers
1k
views
Tips for golfing in Thunno 2
Thunno 2 is a stack-based golfing language with around 400 commands (achieved through overloads) created by me, The Thonnu.
It seems like a good idea to share some tips for golfing in Thunno 2.
Please,...
6
votes
2
answers
452
views
Shortening this Code to process nested tuple even further without the use of max()
I have the code:
...
7
votes
1
answer
917
views
Is there any less code way to make a leaf (eye) shape in CSS?
I'm trying to solve a CSS challenge. It contains a rotated leaf shape (looks like an eye). Score for the challenge depends on amount of characters of the code. Here's my way to make a leaf shape:
<...
16
votes
15
answers
2k
views
Tips for golfing in SVG
SVG is an XML vector graphics markup language embeddable in web content.
Your tips should be at least somewhat specific to SVG.
Please post one tip per answer.
9
votes
5
answers
640
views
Shortest way to convert the result of a test to a string output (e.g. true or false) in bash
I'm trying to shorten a bash solution to a Code Golf challenge, which requires an output of true or false. I've managed to ...
5
votes
3
answers
954
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 ...
0
votes
2
answers
301
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 ...
14
votes
4
answers
2k
views
Tips for improving your score in fastest code challenges
Fastest code is a scoring method on this site where the goal is to write code that is as fast as possible.
From the tag wiki:
The winner of a fastest-code challenge is determined by the runtime ...
9
votes
2
answers
694
views
Inverting string-based binary number in one line in Python
I want to read two strings on separate lines, each string the same length and containing only 0's and 1's, and determine if the first is the one's complement of the second. How succinctly can this be ...
3
votes
0
answers
122
views
Tips for golfing in Arn
Does anyone have tips on how to golf in this language? Please one tip per answer and avoid posting simple and general tips such as "remove whitespace".
Here is the github link and here is ...
2
votes
0
answers
325
views
Shorten this dns txt record request script as much as possible
I have made a short script that will pull dns txt records down from a server and combine them into a single string.
DNS txt records are:
1.website.com
...
5
votes
1
answer
266
views
Need some feedback with PHP+C polyglot code and class/struct properties [closed]
If you consider the following PHP+C polyglot snippet, there is a problem regarding class property access in the printf call:
...
4
votes
3
answers
1k
views
Python: can I shorten this code further for checking substrings
So the golf question was like this:
You are given a number T and then a total of T number of 17-character strings. For each of ...
5
votes
1
answer
784
views
Help me golf this C program checking for string patterns in a sorted hand of cards
I could not think of a better title.
This is a tips question. I'm asking for tips on golfing my code.
I recently took part in a code golf competition in C. The competition ended and I lost. The ...
11
votes
7
answers
874
views
Tips for golfing in Knight
Knight is the Language of the Month for August 2022, and I noticed that it didn't have a tips page, so here it is!
I'm looking for ideas which can be applied to code-golf problems and which are also ...
15
votes
2
answers
2k
views
Can `a?b<c:b>c` be shortened in Javascript?
So I have the situation where I have one boolean value a and, if that one is true and b<c ...