Noodle9
  • Member for 8 years, 1 month
  • Last seen this week
23 answers
17 votes
1k views
Reversencode the given string
2 votes

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

View answer
13 answers
26 votes
2k views
How many bystanders will help?
4 votes

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>[]>1>=len(l)*l.pop()and-~f(l) Try it online! ...

View answer
44 answers
22 votes
2k views
Output a Latin Square
1 votes

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 ...

View answer
44 answers
22 votes
2k views
Output a Latin Square
4 votes

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

View answer
22 answers
21 votes
1k views
Make it prime with the smallest suffix
1 votes

Python 3.8, 80 bytes f=lambda n,a=0:math.perm(p:=int(n+str(a)))**2%-~p<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 ...

View answer
19 answers
23 votes
1k views
Calculate Home Primes
5 votes

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
Calculate Home Primes
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<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
The meeker number sequence
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
Multiplicative Persistence #2
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>=b?b=c,n:r)for(c=0,d=n;a=d,d=d>9;++c)for(;a;a/=10)d*=a%10;d=r;} Try it online!

View answer
12 answers
20 votes
3k views
Fastest draw in the west!
4 votes

C (clang), 343 bytes #include <stdio.h> int main() { const char draw[] = "draw!"; size_t i = 0; while (i < 5) { char c = getchar_unlocked(); i = c==...

View answer
4 answers
12 votes
482 views
The Game of Cat And Mice | With Matrices
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
Code the Levine sequence
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
How often will this test fail?
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
How often will this test fail?
3 votes

Python 3, 48 47 bytes Saved a byte thanks to xnor!!! f=lambda a,n,p:p<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
Check B-powersmoothness
2 votes

C (gcc), 66 64 bytes t;r;p;f(n,B){for(r=p=1;n/++p;r&=t/n<=B)for(t=n;n%p<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
Fibonacci Encoding
8 votes

C (gcc), 51 50 bytes k;f(n){for(k=0;n-=!(++k&k/2););n=log2(k);k+=2<<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
Patterns in Permutations
3 votes

C++ (clang), score 11 #include "patterns_in_permutations.hpp" int main(int argc, char *argv[]) { unsigned int running_time = 60; unsigned int n = 4; std::unordered_map<size_t,...

View answer
21 answers
45 votes
2k views
Summon the sevens
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>>i&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
Write an interpreter generator
3 votes

Python 3, 202 \$\cdots\$ 136 134 bytes lambda s:'%{\nfloat p;\n%}\n%%\n'+''.join(a+' p=p'+b+('(','w(p,')[b>'=']+c+');\n'for a,b,c in s)+'%%\nmain(){yylex();printf("%f",p);}' Try it ...

View answer
31 answers
27 votes
4k views
Count all possible Tweets
1 votes

Python 3.8, 44 31 30 bytes Saved 13 bytes thanks to Makonede!!! Saved a byte thanks to ovs!!! print((x:=17<<16)**281//~-x-1) Try it online!

View answer
10 answers
24 votes
1k views
Unique half rainbows
2 votes

Python 3, 103 97 bytes Saved 6 bytes stealing "borrowing" good golf ideas from ovs's answer!!! lambda n,d=lambda x:[a for a in range(x)if x>=a*a>1>x%a]:all(d(n)!=d(a)for a in range(...

View answer
31 answers
19 votes
2k views
Create all arrays of non-negative integers of length N with sum of parts equal to T
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<bits/stdc++.h> auto ...

View answer
6 answers
17 votes
1k views
Matching ABACABA-type patterns
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
Largest power of 2 that divides \$n\$
2 votes

C (gcc), 15 bytes a;f(n){a=n&-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
Test if a Gray code is Beckett
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&=*a++<*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
Test if a Gray code is Beckett
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<y:u+=x^y, else:r&=u.pop(...

View answer
5 answers
12 votes
513 views
Subarrays With At Least N Distinct Integers
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>len(m))*j:m[a[...

View answer
8 answers
-3 votes
957 views
Let's rise higher
4 votes

4. C (gcc), 106 bytes, 91 distinct bytes, Score: 6132, My Total score: 6132 main(){printf("%d",strlen(" !#$&'*+./0123\4789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`bcghjkoquvwxyz~&...

View answer
14 answers
-3 votes
223 views
Lists of power!
0 votes

Python 3, 55 bytes R=range(10);print([[*{a**-~i%10for i in R}]for a in R]) Try it online!

View answer
28 answers
20 votes
2k views
Semidivisibility
5 votes

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>0>10*n%k;} Try it online! Inputs integers \$n\$ and \$k\$ and returns ...

View answer
1 2 3
4
5
19