Search
Replace print loops by list unpacking If you want to print elements of a list one per line, the straightforward way to do it is a loop: for i in l:print(i) But this can be shortened using list...
import* You can import some libraries and if you find yourself using: from lib import * Remove the space between import and *, because it works for whatever reason.
Use lambdas instead of functions At most times, lambdas tend to make smaller code, which is helpful in golfing. Assigning a lambda is easy, just do: lambda f:whatever There are many answers th...
Ahead, 10 bytes IO"@O+I"W@ This prints N1I+0@. Try it online!
Japt -R, 13 bytes Uses = in place of #. Æ"_/"+Xç¥ÃoÅù Try it Æ"_/"+Xç¥ÃoÅù :Implicit input of integer U Æ :Map each X in the range [0,U) "_/" : Literal str...
Renaming functions A funny, cool, and useful trick. If you have to write a single function multiple times (usually range() on for loops), then you can simply assign a variable by the function's na...
Assign floats while leaving out zeroes Python allows such strange assignment. You can save bytes by removing the number preceding . if it's only 0: i=.5 print(i) Try it online! The same g...
Stax, 8 bytes Ç▐GcΦ≡◘¶ Run and debug it Uses spaces as the staircase fill.
Vyxal o, 5 bytes ~$"," Try it Online! I'd say this counts, because $ is quite literally "swap the top two items on the stack". Explained ~$"," ~$ # Swap the top two items, but peek inste...
APL (Dyalog Extended), 3 bytes ⊢⍮⌽ Try it online! ⊢ the argument ⍮ paired up with ⌽ its reverse
Japt, 3 bytes I/O as an array. cUé Try it cUé :Implicit input of array U c :Concatenate Ué : U rotated right once
Python 3.8 (pre-release), 39 bytes print(x:=input(),y:=input()) print(y,x) Try it online!
Python 3, 874 bytes a="'Twas brillig, and the slithy toves\nDid gyre and gimble in the wabe;\nAll mimsy were the borogoves,\nAnd the mome raths outgrabe.";b="he Jabberwock";c="Beware t";d="One, ...
C (clang), 63 bytes x,y;main(){scanf("%i%i",&x,&y);printf("%i %i\n%i %i",x,y,y,x);} Try it online!
C++ (gcc), 61 bytes float f(int n,float*p,float x){return n?*p+x*f(n-1,p+1,x):0;} Try it online!
Cracks Shaggy's answer: Jelly “¿×⁶ṆḶN{N=ȷṾ» Try it online!
Scala, 42 bytes object>extends App{print("Hello, World!")} Attempt This Online!
For the sake of code golf, you first need to decide if you wish to compete in strictly conforming ("real") C, in which case you can't rely on non-standard extensions, poorly-defined behavior or obs...
C (clang), 59 bytes c;f(int a,(*b)(int,int)){for(c=a;a>1;)c=b(--a,c);return c;} Try it online! This program written by @Hakerh400 in the comments is basically how the other answers before...
Python 3, 82 81 bytes lambda a,b:[a[:i]+b for i in range(len(a)+2)if i>len(a)or b[:len(a)-i]==a[i:]][0] Try it online!
BQN, 8 bytes {𝔽´1+↕𝕩} Try it! basic fold builtin version. Use as a dyadic 1-modifier. Longer than APL since evaluated output is shorter than using first class functions. A more fun recursive...