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
-2 votes
1 answer
176 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 ...
Golfscript-Noob's user avatar
6 votes
3 answers
353 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 ...
Joao-3's user avatar
  • 1,021
0 votes
0 answers
76 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)] ...
Eric Pan's user avatar
5 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 ...
Chi_Iroh's user avatar
  • 163
7 votes
1 answer
299 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 ...
lyxal's user avatar
  • 32.9k
5 votes
0 answers
257 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: ...
user3163495's user avatar
11 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 ...
olivia's user avatar
  • 119
2 votes
2 answers
220 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 ...
Notamathematician's user avatar
6 votes
2 answers
273 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 ...
Command Master's user avatar
-3 votes
1 answer
96 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 ...
Olle Härstedt's user avatar
1 vote
1 answer
179 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: ...
Wheat Wizard's user avatar
  • 97.8k
2 votes
0 answers
89 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)
Dadsdy's user avatar
  • 2,065
4 votes
4 answers
210 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 ...
Dadsdy's user avatar
  • 2,065
5 votes
4 answers
208 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 ...
chunes's user avatar
  • 23.5k
12 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 & ...
brubsby's user avatar
  • 243
-3 votes
1 answer
457 views

What is the ABSOLOUTE 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... ...
Eric's user avatar
  • 105
3 votes
6 answers
911 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,...
The Thonnu's user avatar
  • 17.9k
6 votes
2 answers
389 views

Shortening this Code to process nested tuple even further without the use of max()

I have the code: ...
Dark Programmer's user avatar
7 votes
1 answer
457 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: <...
j-0-n-e-z's user avatar
  • 171
0 votes
0 answers
229 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 (...
aludebe's user avatar
  • 17
16 votes
13 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.
Jakob Lovern's user avatar
9 votes
5 answers
548 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 ...
ShadowRanger's user avatar
5 votes
2 answers
763 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 ...
Felix Schönherr's user avatar
0 votes
1 answer
161 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 ...
DialFrost's user avatar
  • 5,049
13 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 ...
mousetail's user avatar
  • 12.4k
8 votes
2 answers
605 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 ...
Fixee's user avatar
  • 181
3 votes
0 answers
104 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 ...
DialFrost's user avatar
  • 5,049
2 votes
0 answers
276 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 ...
I am Jakoby's user avatar
6 votes
1 answer
217 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: ...
Olle Härstedt's user avatar
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 ...
chnmasta05's user avatar
5 votes
1 answer
736 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 ...
TwilightSparkle's user avatar
11 votes
7 answers
806 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 ...
Aiden Chow's user avatar
  • 13.1k
14 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 ...
Julian Wagner's user avatar
7 votes
4 answers
126 views

Tips for golfing in J-uby

J-uby is the Language of the Month for June 2022, so I'm looking for tips for golfing in it. As usual, please post one tip per answer, and avoid general tips such as "remove whitespace" or &...
naffetS's user avatar
  • 12.3k
11 votes
2 answers
860 views

Curry tips for Haskell programmers

Curry is the Language of the Month this month and some users are starting to get into it, so let's get some tips together. Haskell and Curry are similar in a lot of ways and a lot of tips for Haskell ...
Wheat Wizard's user avatar
  • 97.8k
13 votes
5 answers
865 views

Tips for golfing in Piet

Seeing that the current language for Learn You a Lang for Great Good is Piet, and that we don't seem to have a tips page for Piet yet, I decided to make one. Piet is a stack-based esoteric programming ...
Aiden Chow's user avatar
  • 13.1k
2 votes
0 answers
93 views

Tips for golfing in Fennel

Fennel is a lispy language which compiles to Lua. From its page: Fennel is a programming language that brings together the speed, simplicity, and reach of Lua with the flexibility of a lisp syntax ...
zoomlogo's user avatar
  • 1,655
4 votes
0 answers
215 views

Tips for golfing in Seriously

I am looking for tips to code in this golfing language Seriously, and was wondering what some of the ways for golfing this language is. "Remove comments" is not a tip. Actually is also ...
DialFrost's user avatar
  • 5,049
7 votes
2 answers
298 views

How to shorten Python code involving the sum of reciprocals?

I have a coding problem that goes like this: Given a positive integer \$N\$, return a list of all possible pairs of positive integers \$(x,y)\$ such that $$\frac1x+\frac1y=\frac1N$$ I already solved ...
Aiden Chow's user avatar
  • 13.1k
-9 votes
1 answer
350 views

The right way to return [[0, 0, 0], [0, 1, 0], [0, 0, 0]] [closed]

Here is the program to return [[0, 0, 0], [0, 1, 0], [0, 0, 0]] [[0]*3,[0,1,0],[0]*3] Try it online! Can you shorten this code?...
Fmbalbuena's user avatar
  • 3,841
12 votes
2 answers
341 views

Shortest way to coerce to array

Given a variable a (non array) or (any[]) convert to (any[]) function example(s: string | string[]) { const e = Array.isArray(s) ? s: [s] return e } Is ...
ThomasReggi's user avatar
7 votes
6 answers
199 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 ...
bigyihsuan's user avatar
  • 9,218
10 votes
2 answers
873 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 ...
chnmasta05's user avatar
12 votes
4 answers
544 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" ...
caird coinheringaahin g's user avatar
2 votes
2 answers
150 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,...
DialFrost's user avatar
  • 5,049
4 votes
0 answers
162 views

Tips for golfing in Objective C

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 golfing methods (although I am a python person, I am currently trying ...
DialFrost's user avatar
  • 5,049
8 votes
10 answers
431 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 ...
DialFrost's user avatar
  • 5,049
7 votes
2 answers
213 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 ...
JakeDanzels's user avatar
4 votes
3 answers
719 views

How to shorten the Python code? Part II

Code Python 3, 245 bytes ...
Fmbalbuena's user avatar
  • 3,841
13 votes
3 answers
447 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"...
Bubbler's user avatar
  • 75.2k

1
2 3 4 5
8