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

1k views

Python 3.8, 63 62 bytes lambda s:s[(l:=len(s))//2-1::-1]+s[l//2]*(l&amp;1)+s[:-~l//2-1:-1] Try it online!

2k views

Python 2, 72 $\cdots$ 43 42 bytes Saved 7 bytes thanks to the man himself Arnauld!!! Saved 3 4 bytes thanks to dingledooper!!! f=lambda l:l&gt;[]&gt;1&gt;=len(l)*l.pop()and-~f(l) Try it online! ...

2k views

Python 3, 43 41 bytes Saved 2 byte thanks to caird coinheringaahing!!! lambda n:[(a+a//n)%n for a in range(n*n)] Try it online! Port of my C answer (turns out to be the same as xnor's Python 2 ...

2k views

C (clang), 73 $\cdots$ 49 46 bytes Saved 3 bytes thanks to dingledooper!!! a;f(n){for(a=n*n;a;)printf(&quot;%d &quot;,--a*~n/n%n);} Try it online! Inputs $n$ and prints the Latin Square as a ...

1k views

Python 3.8, 80 bytes f=lambda n,a=0:math.perm(p:=int(n+str(a)))**2%-~p&lt;1and f(n,a+1)or-~a import math Try it online! Inputs $n$ as a string and returns the smallest positive integer that makes ...

1k views

Bash, 84 82 71 bytes Saved 11 bytes thanks to caird coinheringaahing!!! for((;$1-${2-0};)){ set - factor $1|sed 's/.*://;s/ //g'$1;};echo $1 Try it online! Returns the home prime of $n$ quickly ... View answer 19 answers 23 votes 1k views 2 votes Python 3, 109 bytes def f(n,m=0): while n-m: l=m=n;n=0 for i in range(2,l+1): while l%i&lt;1:n=int(f'{n}{i}');l/=i return n Try it online! Quite verbose, returns the home prime of $n$. View answer 17 answers 18 votes 1k views 6 votes C (gcc), 107 $\cdots$ 74 73 bytes Saved 8 bytes thanks to the man himself Arnauld!!! Saved 5 bytes thanks to tsh!!! Saved a whopping 20 bytes thanks to Olivier Grégoire!!! t=10;h=100;a;b;f(n){a=n/h+... View answer 19 answers 16 votes 1k views 1 votes C (gcc), 95 94 bytes Saved a byte thanks to ceilingcat!!! a;b;c;d;r;f(n){for(b=0;n--;r=c&gt;=b?b=c,n:r)for(c=0,d=n;a=d,d=d&gt;9;++c)for(;a;a/=10)d*=a%10;d=r;} Try it online! View answer 12 answers 20 votes 3k views 4 votes C (clang), 343 bytes #include &lt;stdio.h&gt; int main() { const char draw[] = &quot;draw!&quot;; size_t i = 0; while (i &lt; 5) { char c = getchar_unlocked(); i = c==... View answer 4 answers 12 votes 482 views 3 votes Python 3.8, 167 $\cdots$ 159 155 bytes Saved 2 5 bytes thanks to ovs!!! Saved 4 bytes thanks to Delfad0r!!! def f(a,c,r=0): while(l:=sorted([[z,-a.get(c+z,0)]*2for x in(1,1j,1+1j,1-1j)for z in(x,-... View answer 20 answers 21 votes 2k views 5 votes Python 3, 91 87 85 bytes f=lambda n,l=[2]:n and f(n-1,[n+1for n,e in enumerate(l[::-1])for _ in[0]*e])or l[-1] Try it online! Inputs $1$-based index $n$ and returns the $n^{\text{th}}$ element ... View answer 8 answers 13 votes 1k views 1 votes C (gcc), 66 59 54 bytes f(a,n,p,r)float*r,n;{for(*r=1;p--;)*r*=(a-p)/(a-p/n);} Try it online! Calculates the given formula. Returns a float through its last parameter (which is a pointer to an ... View answer 8 answers 13 votes 1k views 3 votes Python 3, 48 47 bytes Saved a byte thanks to xnor!!! f=lambda a,n,p:p&lt;1or(p+~a)/(~-p/n-a)*f(a,n,~-p) Try it online! Straightforward calculation of the given formula. Returns either a float or an ... View answer 19 answers 17 votes 1k views 2 votes C (gcc), 66 64 bytes t;r;p;f(n,B){for(r=p=1;n/++p;r&amp;=t/n&lt;=B)for(t=n;n%p&lt;1;n/=p);t=r;} Try it online! Takes two integers $n$ and $B$ as input and returns $1$ if $n$ is $B$-... View answer 21 answers 18 votes 3k views 8 votes C (gcc), 51 50 bytes k;f(n){for(k=0;n-=!(++k&amp;k/2););n=log2(k);k+=2&lt;&lt;n;} Try it online! Uses the formula from Etheryte's Japt answer. Returns the Fibonacci code word for input $n$ in ... View answer 3 answers 7 votes 352 views 3 votes C++ (clang), score 11 #include &quot;patterns_in_permutations.hpp&quot; int main(int argc, char *argv[]) { unsigned int running_time = 60; unsigned int n = 4; std::unordered_map&lt;size_t,... View answer 21 answers 45 votes 2k views 2 votes Python 3, 200 $\cdots$ 183 181 bytes def f(a,R=range): for b,n in sorted((bin(i).count('1'),i)for i in R(512)): c=[[a[i],7][n&gt;&gt;i&amp;1]for i in R(9)] if len({(sum(c[3*i:3*i+3]),sum(c[i:9:... View answer 16 answers 22 votes 2k views 3 votes Python 3, 202 $\cdots$ 136 134 bytes lambda s:'%{\nfloat p;\n%}\n%%\n'+''.join(a+' p=p'+b+('(','w(p,')[b&gt;'=']+c+');\n'for a,b,c in s)+'%%\nmain(){yylex();printf(&quot;%f&quot;,p);}' Try it ... View answer 31 answers 27 votes 4k views 1 votes Python 3.8, 44 31 30 bytes Saved 13 bytes thanks to Makonede!!! Saved a byte thanks to ovs!!! print((x:=17&lt;&lt;16)**281//~-x-1) Try it online! View answer 10 answers 24 votes 1k views 2 votes Python 3, 103 97 bytes Saved 6 bytes stealing &quot;borrowing&quot; good golf ideas from ovs's answer!!! lambda n,d=lambda x:[a for a in range(x)if x&gt;=a*a&gt;1&gt;x%a]:all(d(n)!=d(a)for a in range(... View answer 31 answers 19 votes 2k views 6 votes C++ (gcc), 164 $\cdots$ 153 151 bytes Saved 3 bytes thanks to ceilingcat!!! Added 7 bytes to fix a bug kindly pointed out by Neil. Saved 2 bytes thanks to Neil!!! #import&lt;bits/stdc++.h&gt; auto ... View answer 6 answers 17 votes 1k views 1 votes Python 3, 205 bytes def f(w): R=range(len(w));s=[w[i:j+1]for i in R for j in R[i:]];v=[*s];n=len(s);r=[] while n:r+=[n];s={i+j+i for i in s for j in v if i+j+i in w};n=sum(len({w.find(a,b)for b in ... View answer 30 answers 15 votes 944 views 2 votes C (gcc), 15 bytes a;f(n){a=n&amp;-n;} Try it online! Inputs a positive integer $n$ and returns $2^a$ which is the largest power of $2$ such that $2^a\mid n$. View answer 11 answers 26 votes 2k views 1 votes C (gcc), 95 bytes t;r;b;e;f(a,n)int*a;{int l[n];for(b=e=r=1;--n;)t=*a^a[1],r&amp;=*a++&lt;*a?l[e++]=t,1:l[b++]==t;r=r;}; Try it online! Port of my Python answer. Inputs an array of integers and its ... View answer 11 answers 26 votes 2k views 3 votes Python 3, 138 $\cdots$ 102 95 bytes Saved 13 bytes thanks to rak1507!!! Saved 7 bytes thanks to dingledooper!!! def f(b): r,*u=1, for x,y in zip(b,b[1:]): if x&lt;y:u+=x^y, else:r&amp;=u.pop(... View answer 5 answers 12 votes 513 views 2 votes Python 3, 189 $\cdots$ 157 152 bytes Saved a whopping 16 32 bytes thanks to ovs!!! Saved 5 bytes thanks to Jonathan Allan!!! def f(a,n): c=0;m={};S=j=len(a) for v in a: while(n&gt;len(m))*j:m[a[... View answer 8 answers -3 votes 957 views 4 votes 4. C (gcc), 106 bytes, 91 distinct bytes, Score: 6132, My Total score: 6132 main(){printf(&quot;%d&quot;,strlen(&quot; !#$&amp;'*+./0123\4789:&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`bcghjkoquvwxyz~&...

223 views
C (gcc), 25 24 23 bytes Saved a byte thanks to AZTECCO!!! Thanks to dingledooper who found and fixed a bug!!! f(n,k){n=n%k&gt;0&gt;10*n%k;} Try it online! Inputs integers $n$ and $k$ and returns ...