Search
Jelly, 1 byte x Try It Online! x is Jelly's replicate atom. Since Jelly is inspired by languages like J, APL, etc, it is no surprise that is has an atom for a fairly important function.
jq, 32 27 bytes -5 bytes (thank you Razetime) .n as$n|.s/""|map(.*$n)|add Try it online!
C (gcc), 56 bytes i;f(s,n)char*s,n;{for(;*s;s++)for(i=n;i--;putchar(*s));} Try it online! My attempt at recursion ended up at 61 bytes: o;f(s,n)char*s,n;{for(o=n;*s&&n--;putchar(*...
Replace range() if $n < 4$ If you're using a for loop, you're probably using range() for the list count. You can actually replace it if the number inside range() is less than 4. Why? Examine th...
Japt -m, 2 bytes pV Try it pV :Implicit map of first input string p :Repeat V :Second input times
JavaScript, 36 bytes s=>n=>s.replace(/./g,`$&`.repeat(n)) Try it online!
Rockstar, 90 bytes listen to S split S listen to N O's"" while S roll S into C let C be*N-0 let O be+C say O Try it here - code will need to be pasted in; s goes on the first line of ...
Vyxal, 2 bytes ∆ṙ Try it Online! That cheap builtin.
Japt -Q, 15 12 bytes à üÊËx_×*JpE -3 bytes thanks to @Shaggy Uses Vieta's. Try it
JavaScript (Node.js), 91 68 65 bytes s=>s.toUpperCase().match(/(?<=^| )[A-Z]|:|;|(?<=[.?!]) /g).join`` Assumes that the original text is properly formatted (has a space after punctuati...
Python 3, 99 bytes r=[*range(26)] a="ABCDEFGHIJKLMNOPQRSTUVWXYZ" for i in r+r[-2::-1]:print(" "*(26-i)+a[:i]+a[i::-1]) Try it online!
Python 3, 46 bytes Saved 8 bytes thanks to Shaggy! lambda n:[n-i*i or exit(1)for i in range(1+n)] Try it online! Python 3.8 (pre-release), 50 54 52 bytes Fixed a silly mistake thanks to Sh...
Combine loops Suppose you have a for loop in another, maybe a couple of times, and nothing else inside of the outer for loops (except for the first for loop since anything outside won't be involve...
* == and If you want to check if two booleans or integers and want to check if both of them are true in an if statement, then you can leave out and to replace it with *: x=2;y=3 if x and y:pri...
Use a+=[b] instead of a.append(b) The title says it all. a=[];b=10;print(a) a+=[b];print(a) Try it online!
Haskell, 352 bytes f a=let{(d,e)=y$filter(>'-')a;f=drop 1e;g=0!h;h=fst n;i=scanr(:)[]h;(j,k)=elem '.'f%(1!head(filter(\a->a>[]&&elem(a++a)i)i++[[last$'0':h]]));(l,m)=(read('0':d...
JavaScript (Node.js), 242 234 bytes s=>([l,p,i,j,_,r]=/(-)?\+?(\d*)\.?(\d*?)(((\d+)\6|\d)\.|$)/.exec(s),[i,r]=c(c([i|0,1],[j|0,10**(l=j.length)]),[r=r||'0',10**l*(10**r.length-1)]),[(p?-i:i)/(j...
Japt, 15 bytes É©Òß[U*3ÄUz]gUv Try it É©Òß[U*3ÄUz]gUv :Implicit input of integer U É :Subtract 1 © :Logical AND with Ò :Negate the ...
BQN, 31 28 bytes {1+(1≠𝕩)◶¯1‿𝕊2(|⊑÷˜∾1+3×⊢)𝕩} Try it online! An anonymous function which takes a number. the ¯1 branch is a bit tacky but saves a byte over (1+𝕊).
Replace if/else expressions by array subscripts Consider the statement a=b if x<y else c You can get rid of the expensive keywords by using the implicit conversion of boolean values to inte...
Replace n+1 with -~n and n-1 with ~-n For integers, n+1 and ~-n have the same value, as have n-1 and -~n. While the expressions themselves have the same lengths, the replacements often allow to s...
Python 3, 72 69 bytes lambda l:''.join(sum(zip(*[[*i]+['']*max(map(len,l))for i in l]),())) Try it online! Uses this method to flat zip, with modifications to pad the shorter lists.
Python 2, 58 54 bytes lambda l:''.join(filter(None,sum(map(None,'',*l),()))) Try it online! Amazingly, shorter than my Python 3 answer! Uses this method to zip unequal-length lists and this me...
Ruby, 51 bytes ->a{(0..a.map(&:size).max).map{|n|a.map{_1[n]}}*""} ->a{ } # lambda taking array `a` (0..a.map(&:size).max) ...
FALSE, 198 bytes [" on the wall"]c:[$." bottle"$1=~["s"]?" of beer"]b:99[$1>][b;!c;!", "b;!". Take one down, pass it around, "1-b;!c;!". "]#1b;!" on the wall, "1b;!". Go to the store and b...