Skip to main content
16 votes

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

C (gcc), 40 bytes by Sisyphus, exit by stack overflow i;main(){main(dprintf(i++<9999,"%d,"));} Try it online! C (gcc), 41 bytes by dingledooper <...
l4m2's user avatar
  • 24.5k
14 votes

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

C (gcc) (Linux only), 31 bytes main(){system("seq -s, 9999");} Try it online!
AShelly's user avatar
  • 4,651
11 votes
Accepted

Shortest C code to display argv in-order

C (gcc), 37 bytes main(c,v)int*v;{for(;*v;)puts(*v++);} Try it online! When using 32-bit, you can use int to store a pointer ...
l4m2's user avatar
  • 24.5k
7 votes

Tips for golfing in Uiua

Use complex numbers The length of a vector given by a pair of numbers can be found with sqrt + both(pow 2) for 7 glyphs (or more idiomatically ...
Tbw's user avatar
  • 2,083
6 votes

Situations when recursion helps

Adjusting argument order E.g. Decide if 3 sticks construct a right triangle: ...
l4m2's user avatar
  • 24.5k
6 votes

How can I reduce the characters in the following python code?

Python 3.8 (pre-release), 46 bytes You can use exit instead of print to save 1 byte. This displays the same for me in a terminal running on Windows and displays the string in the Debug section in TIO....
ElPedro's user avatar
  • 6,459
5 votes

Tips for Golfing in Vyxal 3

Compress Strings and Numbers Like Vyxal 2 before it, Vyxal 3 has dictionary string compression and base-based compression. However, in Vyxal 3, dictionary strings use Jelly's sss and base-based ...
lyxal's user avatar
  • 33.6k
4 votes

Tips for golfing in R

Numeric Tricks Ignoring precision error: x%/%1 instead of floor(x) (integer part for positive x) ...
qwr's user avatar
  • 12.1k
4 votes

Tips for golfing in (,) in-paren-comma

Nest Variables When you have a variable (lets say A) with a index at least two more than a constant, fairly large variable B (or at least constant while you use A), you can usually instead have A be ...
Dadsdy's user avatar
  • 2,095
4 votes
Accepted

Shorten this recursive even fibonacci implementation

Haskell, 27 bytes g=2:zipWith((+).(*4))g(0:g) Try it online! Uses the recursive relationship \$g_n = 4 g_{n-1} + g_{n-2}\$.
xnor's user avatar
  • 145k
4 votes

Shortest C code to display argv in-order

C (GCC), 34 bytes main(c,v)int*v;{execvp("echo",v);} Attempt This Online! C (GCC) with -m32 flag, 28 bytes thanks to @...
matteo_c's user avatar
  • 6,480
4 votes

Tips for golfing in Uiua

Use /f instead of f°⊟ If you have an array with two rows, and want to apply a |2.1 function ...
Joao-3's user avatar
  • 1,183
3 votes

Tips for golfing in Retina

Horizontal or Vertical Mirroring in Retina 0.8.2 If the amount of mirroring is a constant, then it's easy enough: duplicate the string, then reverse the appropriate half. For instance, suppose the ...
Neil's user avatar
  • 172k
3 votes

Tips for golfing in sed

use the e flag on s for simplifying things your output may depend on which shell sed is using. I'll only include things that work on TIO at time of writing. I know there are lots of decimal to unary ...
guest4308's user avatar
  • 643
3 votes

Tips for golfing in JavaScript

Length of deprecating array +1 1+X.length X.push(0) // 1 byte shorter
l4m2's user avatar
  • 24.5k
3 votes

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

Omit Braces When Possible Unlike some golfing languages, Acc!! does not automatically close braces. However, a known bug in the official interpreter occasionally allows for the omission of braces. Due ...
Mukundan314's user avatar
  • 12.3k
3 votes

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

Unary output without loops The official interpreter implements the Write command using ...
Mukundan314's user avatar
  • 12.3k
2 votes

Tips for golfing in C

If you have some variables declared in a row : int a,b,c,d; You can access b by (&a)[1], or c by (&a)[2] ... It can be interesting there : ...
Rémi's user avatar
  • 41
2 votes

Tips for golfing in JavaScript

Avoid typeof typeof x === 'number' is pretty verbose if you need to distinguish your input values by type. (Granted, this is ...
Bergi's user avatar
  • 1,047
2 votes

Tips for golfing in C++

If you have some variables declared in a row : int a,b,c,d; You can access b by (&a)[1], or c by (&a)[2] ... It can be interesting there : ...
Rémi's user avatar
  • 41
2 votes

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

This may be much shorter for Python3 and inputs as integer a,b,c=map(int,open(0)) For example expected input is: 23 45 56 The above golf code will assign ...
Nishant Patel's user avatar
2 votes

Tips for golfing in VBA

Implicit type convertion - Double to Integer This trick can spare you the rounding step if you have a floating point number and you need an integer index. Consider you have an array ...
int 21h Glory to Ukraine's user avatar
2 votes

Tips for golfing in Prolog

findall/3 will evaluate arithmetic expressions. I expected to have to use is/2 and another variable for that, but no: ...
TessellatingHeckler's user avatar
2 votes

Tips for golfing in Kotlin

Using String.split(",") Use this golfing when creating an List<String> with more than two strings ...
PresentKim's user avatar
2 votes

Tips for golfing in Swift

Type Inference Swift's type checker is very good at inferring types — a blessing like no other when golfing — but sometimes it needs a little help. Consider this code (borrowed from one of my own ...
macOSisthebestOS's user avatar
2 votes

Tips for Golfing in Vyxal

Use string interpolation Apparently automatic string interpolation (Π) has been incorporated into Vyxal from v2.13.3 onwards. When used inside a string, ...
math scat's user avatar
  • 9,408
2 votes

Tips for Golfing the Lambda Calculus & Friends

Implementations on the Web For those who are into standard Lambda calculus/combinator calculus, it is a shame that it isn't easy to find an easy-to-use interpreter and converter, especially the ones ...
Bubbler's user avatar
  • 77k
2 votes

Tips for shortening this type-safe addition in JavaScript

JavaScript, 23 bytes c=(a,b)=>(a||0)-(-b||0)
joinerof's user avatar
2 votes

Tips for golfing in (,) in-paren-comma

Take advantage of flags There are a ton of flags currently existing. 'D' is only useful for debugging, but all others can be useful. The 's'/'S' flags are only useful for golfing, and can help cut ...
Dadsdy's user avatar
  • 2,095
2 votes

Tips for golfing in (,) in-paren-comma

Nest print statements When you are printing values of variables you could have a situation like this: (,,(()))(,,(()())) Where we are printing var1 followed by ...
Leo's user avatar
  • 12.7k

Only top scored, non community-wiki answers of a minimum length are eligible