Noodle9
• Member for 8 years, 1 month
• Last seen this week

2k views

Python 3, 199 $\cdots$ 182 173 bytes f=lambda s,n=0:s&lt;'.'and f(s[1:],1-n)or len(s)&gt;1and f(s&lt;'2'and s[1:]or(s[0]==s[1]and'-1'or{'ij':'k','jk':'i','ki':'j','ji':'-k','kj':'-i','ik':'-j'}[s[:...

2k views

C (gcc), 116 110 106 bytes Saved 3 bytes thanks to the man himself Arnauld!!! Saved 4 bytes thanks to ceilingcat!!! d;g;p;r;f(char*s){for(p=r=1;*s;r*=pow(p,17088/ *s++%75%14|1))for(g=0;!g;)for(g=d=p++...

593 views

C (gcc), 52 $\cdots$35 23 bytes Saved 8 bytes thanks to tsh!!! f(n){n=logb(pow(n,n));} Try it online! Uses the formula from Manish Kundu's Python answer.

4k views

C (gcc), 70 69 bytes Saved a byte thanks to EliteDaMyth!!! f(x,y,z,i)float x,y,z;{for(;++i&lt;11;)printf(&quot;%f &quot;,2*(x*y+x*z+i*y*z));} Try it online! Prints out the surface areas starting at ...

3k views

Python 3, 96 92 91 bytes f=lambda l,n=1:n&lt;=len(l)and-~f([v-(e&lt;n)for e,v in enumerate(sorted(l)[::-1])if(e&lt;n)-v],n+1) Try it online! Simply &quot;eats&quot; $1$ each of the $n$ cookies ...

1k views

C (gcc), 67 $\cdots$ 60 58 bytes Saved a byte thanks to ceilingcat!!! Saved 4 6 bytes thanks to tsh!!! Saved 2 bytes thanks to rtpax!!! y;f(p){p=(~-sscanf(p,&quot;1.%d.%d&quot;,&amp;p,&amp;y)*y+p*p+...

1k views

Python 3, 72 bytes f=lambda p,n=0:float(p[2:])&lt;[9,11,13,15,16.2,17,18][n]and n+1or f(p,n+1) Try it online!

1k views

Python 3.8, 91 bytes import math f=lambda n,m,N=0,D=1:n and f(n-1,m,N*n**m+D,D*n**m)or(N/(G:=math.gcd(N,D)),D/G) Try it online! Inputs $n$ and $m$ and returns the numerator and denominator of $... View answer 37 answers 22 votes 2k views 2 votes C (gcc), 45 43 bytes Saved 2 bytes thanks to Olivier Grégoire!!! t;s;f(x,n){for(s=t=0;n--;)s+=t=t*10+x;n=s;} Try it online! View answer 19 answers 24 votes 1k views 4 votes C (gcc), 45 41 bytes f(n){n=n--&lt;3?n:-~n*n*(f(n)+n*f(n-1)/2.);} Try it online! Inputs a positive integer$n$and returns$a_n$. View answer 18 answers 26 votes 2k views 3 votes C (gcc), 31 38 36 bytes Added 7 bytes to fix a problem kindly pointed out by Nick Kennedy and Arnauld. f(a,n)int*a;{n=n?f(a,n--&amp;n)+a[n]:0;} Try it online! Inputs a pointer$a$to the Fenwick ... View answer 18 answers 26 votes 2k views 4 votes Python 3, 36 34 bytes Saved 2 bytes thanks to the man himself Arnauld!!! f=lambda a,n:n and a[n]+f(a,n&amp;~-n) Try it online! Inputs Fenwick Tree$a$(with a leading$0$) and$1$-indexed$n$... View answer 12 answers 5 votes 912 views 2 votes C (gcc), 70 bytes a;i;r;f(x,b,l)int*b;{for(a=1,r=i=0;x;x/=10)r+=x%10*a,a*=b[i++%l];x=r;} Try it online! Inputs a non-negative integer in base 10, a pointer to the array of bases, and the array's ... View answer 23 answers 18 votes 2k views 1 votes C (gcc), 45 bytes D(m,n){m=m*n?D(m-1,n)+D(m-1,n-1)+D(m,n-1):1;} Try it online! View answer 18 answers 8 votes 1k views 2 votes C (clang), 60 58 bytes Saved 2 bytes thanks to G. Sliepen!!! f(n,x,y,s){(n+=y)%x?f(n,x,y,s+1):printf(&quot;%d %d&quot;,n/x,s+1);} Try it online! Uses the formula from Jonathan Allan's comment to ... View answer 33 answers 22 votes 2k views 3 votes C (clang), 54$\cdots$52 43 bytes Saved 9 bytes thanks to att!!! f(g(),*L,*I,n){for(;n--;)L[*I++]=g(L[*I]);} Try it online! Inputs a pointer to a function$g$(inputting an int parameter and ... View answer 3 answers 6 votes 366 views 2 votes C (clang), 5.383 seconds #include &lt;strings.h&gt; #include &lt;string.h&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; unsigned int f(char* str) { unsigned int count = 0; char ... View answer 15 answers 15 votes 1k views 1 votes C (gcc), 194$\cdots$180 174 bytes Saved 6 bytes thanks to ceilingcat!!! w=52;n;c;i;j;a[156];f(s,l)int*s;{for(c=i=0;i&lt;w*3;)a[n=i++]=i%w;for(;n;++c)for(j=0;j&lt;l;++j)for(i=!wmemcpy(a+w,a,w);i&... View answer 14 answers 21 votes 2k views 1 votes C (gcc), 183$\cdots$149 148 bytes g;t;l;i;e(a,b)int*a,*b;{i=*a&gt;*b;i-=*a&lt;*b;}f(k,n){int a[g=l=n&lt;&lt;k];for(;g||k--;g=qsort(a,l,4,e))for(i=l;i--;a[i]=g?i+1:t%2?3*t+1:t/2)t=a[i];i=a[n-1];} ... View answer 14 answers 17 votes 951 views 2 votes C (clang), 98 96 87 bytes i;j;t;f(char*s){for(;*s;++s)for(i=0,j=index(s+1,*s)-s;j&gt;i;s[j--]=t)t=s[i],s[i++]=s[j];} Try it online! Inputs a pointer to a string and swap encodes the string in place. View answer 14 answers 17 votes 951 views 0 votes Python 3.8, 96 bytes f=lambda s,i=0:i&lt;len(s)and f(i&lt;(j:=s[i+1:].find(s[i])+i+1)and s[:i]+s[j:i:-1]+s[j:]or s,i+1)or s Try it online! View answer 16 answers 11 votes 2k views 1 votes Bash, 24 bytes echo 32767/RANDOM|bc -l Try it online! Prints a random number between$1$and$\infty$. View answer 17 answers 8 votes 1k views 1 votes C (gcc), 82 bytes a;c;i;r;f(x,b,l)int*b;{for(a=1,r=i=0;x;x/=c)c=b[i++%l],r+=x%c*a,a*=10,x-=x%c;x=r;} Try it online! Inputs a non-negative integer in base$10$, a pointer to the array of bases, and ... View answer 12 answers 15 votes 1k views 2 votes Python 3, 120 102 88 bytes Saved a whopping 18 32 bytes thanks to ovs!!! f=lambda n,r=1,a=0,b=1:n&gt;1and f(n-1,r,b,a+b)or-((1+5**.5)*r//2!=b*r//a or~f(n,r*10,a,b)) Try it online! View answer 74 answers 21 votes 4k views 4 votes Day 0. C (gcc), 5 bytes f(){} Try it online! Next line: YOU ARE LIKELY TO BE EATEN BY A GRUE (MC Frontalot &quot;It Is Pitch Dark&quot;) View answer 64 answers 50 votes 10k views 8 votes C (gcc), 48 bytes f(){printf(&quot;Min%sraft&quot;,rand()%10000?&quot;ec&quot;:&quot;ce&quot;);} Try it online! Version closer to$\frac{1}{10000}$For a pseudorandomness as close to$\frac{1}{...

388 views

C (gcc), 82 80 79 bytes Saved 2 3 bytes thanks to ceilingcat!!! a;b;c;f(char*s){sscanf(s+1,&quot;%d,%d%c&quot;,&amp;a,&amp;b,&amp;c);a-=*s&amp;1;b-=c&lt;42;b=a*~a-b*~b&gt;&gt;1;} Try it online!

2k views

C (gcc), 38 27 bytes Saved 11 bytes thanks to AZTECCO!!! f(n,b){n=n%b?0:1+f(n/b,b);} Try it online!

1k views
C (clang), 84 $\cdots$ 81 75 bytes Saved 6 bytes thanks to AZTECCO!!! b;i;j;f(*a,l){for(i=-1;++i&lt;l;printf(&quot;%d &quot;,b))for(b=j=l;j--;)b-=a[i]!=a[j];} Try it online! Inputs a pointer to an ...
C (gcc), 54 $\cdots$ 39 37 bytes Saved 8 bytes thanks to dingledooper!!! Saved 2 bytes thanks to ceilingcat!!! o(f,g,a,b)int f(),g();{g(f(a),f(b));} Try it online!