2022 Developer Survey is open! Take survey.

New answers tagged

1 vote

Fibonacci function or sequence

rSNBATWPL, 28 bytes n~cond{n<2}{1}${n- 1}+{n- 2} Try It Online!
user avatar
  • 4,026
0 votes

Find the highest unique digit

Factor, 27 bytes [ non-repeating ?supremum ] Attempt This Online! non-repeating Get only the elements of a sequence that don't ...
user avatar
  • 8,748
0 votes

Output the sign

A0A0, 18 bytes I0L0V0O0 G-1G-1G-1 Explanation: ...
user avatar
0 votes

Output the sign

Microscript II, 21 bytes N(s""+K45=("-1"ph)!_) todo: add an explanation
user avatar
  • 3,224
0 votes

There's more than one way to skin a set

T-SQL, 114 bytes Using a table variable as input ...
user avatar
  • 3,524
2 votes

There's more than one way to skin a set

PARI/GP, 53 bytes a->[k-1|k<-[1..#p=Vec(prod(i=1,#a,1+x^a[i]))],p[k]>1] Attempt This Online! Using generating functions. For input \$\{a_1,\dots,a_n\}\$, ...
user avatar
  • 32.8k
0 votes

Print 0 to 100 without 1-9 characters

PostScript: 11 bytes 00000000: 8800 8801 8864 7b3d 7d92 48 .....d{=}.H A tokenized version of 0 1 100{=}for.
user avatar
0 votes

How long is my number?

K (ngn/k), 17 bytes {#$$[x<0;x*-1;x]} Try it online! Can't handle big numbers correctly, i.e. 33107638153846291829. Still ...
user avatar
  • 501
0 votes

How long is my number?

Batch, 101 bytes @set/pi= @set o=-1&if %i:~,1%==- set o=-2 :l @set/ao+=1&if %i%. neq . set i=%i:~,-1%&goto:l @echo %o% 89 bytes ...
user avatar
  • 1,851
1 vote

There's more than one way to skin a set

Zsh, 75 bytes for i;a=({$i,}+0$^a) for s ($a)((++S[s])) for s ("$S[@]")((++k,s>1))&&<<<$k Try it online! Accidentally out-golfed my ...
user avatar
0 votes

How long is my number?

Desmos, 31 bytes g=abs(a) f(a)=floor(log(g+0^g)) Try it on Desmos!
user avatar
  • 4,026
1 vote

How long is my number?

Factor + project-euler.common, 13 bytes number-length Try it online!
user avatar
  • 8,748
0 votes

Fibonacci function or sequence

Factor + benchmark.fib3, 3 bytes fib Try it online! And a non- built-in version: Factor, 32 bytes ...
user avatar
  • 8,748
1 vote

There's more than one way to skin a set

Japt, 12 bytes à mx ü lÉ câ Try it
user avatar
  • 35.4k
0 votes

Calculate the area of a regular polygon

05AB1E, 7 bytes žqI/ż* Try it online or verify all test cases. Explanation: ...
user avatar
0 votes

Calculate the area of a regular polygon

Factor, 19 bytes [ pi over / tan * ] Try it online!
user avatar
  • 8,748
3 votes

There's more than one way to skin a set

Attache, 33 bytes ${{_~x>1}\Unique@x}##Sum=>Subsets Try it online! Happy 1,000 answers on this site to me? Explanation ...
user avatar
0 votes

Count up forever

Factor + lists.lazy, 19 bytes 1 lfrom [ . ] leach Try it online!
user avatar
  • 8,748
1 vote

Count up forever

A0A0, 45 bytes A0A0 A0C3G1G1A0 A0V1O0P9S1A0 A0A1G-3G-3A0 G-3 Prints 1 up to infinity, delimited by tabs. This uses a basic infinite loop construct, which executes ...
user avatar
3 votes

There's more than one way to skin a set

Desmos, 96 bytes n=L.length S=[total(floor(mod(i/2^{[0...n]},2))L)fori=[0...2^n-1]].sort f(L)=S[S[2...]=S].unique Try it on Desmos! How it works Conceptually ...
user avatar
  • 15.9k
1 vote

There's more than one way to skin a set

Charcoal, 21 bytes ⊞υ⁰FAF⁺υι⊞υκIΦ⌈υ‹¹№υι Try it online! Link is to verbose version of code. Explanation: ⊞υ⁰ Start with ...
user avatar
  • 142k
1 vote

There's more than one way to skin a set

Desmos, 148 bytes ...
user avatar
  • 3,880
1 vote

There's more than one way to skin a set

Brachylog, 13 bytes ⊇ᶠ+ᵐ{⊇Ċ=}ᶠhᵐd Try it online! Explanation ...
user avatar
  • 35.2k
1 vote

There's more than one way to skin a set

05AB1E, 7 bytes æOТ≠ÏÙ Try it online or verify all test cases. Or alternatively: æO{Åγ≠Ï Try it online or verify all test ...
user avatar
1 vote

There's more than one way to skin a set

Python, 79 75 bytes -4 bytes thanks to pxeger! def f(a,*o): for x in a: for d in*o,0:o.count(v:=x+d)==1!=print(v);o+=v, Attempt This Online! Python 2, 102 bytes Much longer, but more fun ;) (and ...
user avatar
  • 53.4k
1 vote

There's more than one way to skin a set

Python 3, 106 bytes g=lambda s:{s}|{q for n in s for q in g(s-{n})} def f(s):*q,=map(sum,g(s));*map(q.remove,{*q}),;return{*q} Try it online! Requires a ...
user avatar
  • 6,240
1 vote

There's more than one way to skin a set

Burlesque, 12 bytes R@)++JNB\\NB Try it online! ...
user avatar
1 vote

There's more than one way to skin a set

Python 3.8, 152 bytes -5 bytes thanks to ovs, -4 bytes thanks to pxeger, and -2 bytes thanks to ...
user avatar
  • 565
4 votes

There's more than one way to skin a set

J, 28 19 bytes [:~.@(#~1-~:)(,,+)/ Try it online! -9 thanks to ovs for the (,,+)/ trick for calculating all subset sums! ...
user avatar
  • 26.6k
2 votes

There's more than one way to skin a set

Haskell, 120 bytes g(s,d)i=(i:s,if i`elem`s&&i`notElem`d then i:d else d) f c=snd.foldl g([],[])$map(sum.zipWith(*)c)(sequence[[0,1]|_<-c]) Try it ...
user avatar
2 votes

There's more than one way to skin a set

Factor + math.combinatorics math.unicode, 37 bytes [ all-subsets [ Σ ] map duplicates ] Try it online!
user avatar
  • 8,748
1 vote

Print 0 to 100 without 1-9 characters

Minecraft, 217 bytes + ? From left to right the commands in the command blocks are ...
user avatar
  • 419
5 votes

There's more than one way to skin a set

R, 66 bytes \(S,t=table(unlist(Map(\(i)combn(S,i,sum),seq(!S)))))names(t[t>1]) Attempt This Online!
user avatar
  • 10.9k
7 votes

There's more than one way to skin a set

Wolfram Language (Mathematica), 34 bytes ##2&@@@Gather[Tr/@Subsets@#]⋃{}& Try it online! ...
user avatar
  • 15.2k
5 votes

There's more than one way to skin a set

Vyxal, 8 bytes ṗṠsĠ~Ḣvh Try it online or run all test cases. sĠ~Ḣvh is the shortest way I can think of to keep only duplicates, ...
user avatar
  • 4,026
3 votes

There's more than one way to skin a set

Jelly, 8 bytes ŒP§œ-Q$Q Try it online! How it works ...
user avatar
8 votes

There's more than one way to skin a set

BQN, 15 bytesSBCS (1=⊒)⊸/·⥊(∾∾+)˝ Run online! BQN, 19 bytesSBCS (1=⊒)⊸/<+´∘ר⟜⥊⟜↕2¨ Run online! ...
user avatar
  • 53.4k
4 votes

There's more than one way to skin a set

JavaScript (V8), 69 bytes a=>(g=([v,...a],s=0)=>v?g(a,s+v)|g(a,s):(g[s]=-~g[s])-2||print(s))(a) Try it online! Commented ...
user avatar
  • 166k
1 vote

Palindromic Powers

Burlesque, 48 bytes -.{J<-==}FO9.-f{Jbcjfc:-.jqLGZ]{J@1.>jXXsm&&}ay} Try it online! ...
user avatar
2 votes

Sort by Multiplying

Desmos, 78 bytes n->min(n,i.length)+1,o->join(o,i[n]floor(o[n-1]/i[n]+1)) i=\ans_0 n=2 o=[i[1]] Try It On Desmos! Try It On Desmos! - Prettified
user avatar
  • 3,880
2 votes

Sort by Multiplying

PARI/GP, 25 bytes a->i=0;[i=c*(i\c+1)|c<-a] Attempt This Online!
user avatar
  • 32.8k
2 votes

Sort by Multiplying

Factor, 35 bytes [ 0 [ tuck /i 1 + * ] accumulate* ] Attempt This Online!
user avatar
  • 8,748
2 votes

Sort by Multiplying

Rust, 59 bytes |mut l:Vec<u8>|{for i in 1..l.len(){l[i]*=l[i-1]/l[i]+1};l} Try it online! I am still learning rust, but I am sure there is a better solution ...
user avatar
  • 399
3 votes

Sort by Multiplying

TI-Basic, 43 40 37 bytes Prompt A For(I,1,dim(ʟA ʟA(I)(1+int(Ans/ʟA(I→ʟA(I End ʟA -6 bytes thanks to MarcMush.
user avatar
  • 1,851
1 vote

Palindromic Powers

Julia 1.0, 55 bytes !n=filter(i->"$i"==reverse("$i")&&i∈(r=2:i)'.^r,10:n) Try it online! with a beautiful \$O(n^3)\$ complexity and ...
user avatar
  • 4,824
2 votes

Sort by Multiplying

Julia 1.0, 27 bytes !L=(x=0;L.|>i->x=(x÷i+1)i) Try it online!
user avatar
  • 4,824
1 vote

Sort by Multiplying

MathGolf, 7 bytes æ`/)*]ç Try it online. Explanation: ...
user avatar
1 vote

Palindromic Powers

Java 8, 133 bytes ...
user avatar
3 votes

Palindromic Powers

C (gcc), 111 bytes i,t,r;g(n){r=9/--n||g(n);for(t=n;t;t/=10)r=r*10+t%10;for(t=i=2;r==n&i<n;)t=t/n?t-n?++i:printf("%d\n",i=n):t*i;} Try it online!
user avatar
  • 15.2k
3 votes

Music with pi and e

Vyxal, 29 bytes ƛkAf7Ẏ2Ǔ:3Ẏ\'vJJn∆iin∆i›∆ė4/" Try it Online! or Run both test cases! Port of 05AB1E. If it can't output rationals instead of decimals, add <...
user avatar
  • 4,026

Top 50 recent answers are included