Skip to main content
53 votes

Arbitrary-length currying

JavaScript (ES6), 18 bytes f=n=>m=>m?f(m+n):n Pass a falsy value to retrieve the sum. Zeros could be allowed for a cost of 2 bytes. Try it online ...
Neil's user avatar
  • 172k
33 votes

Pointlessly make your way down the alphabet

Dyalog APL Extended, 4 bytes ⌽∘⍳¨ Try it online! ...
dzaima's user avatar
  • 20.3k
26 votes

1, 2, 4, 8, 16, ... 33?

Python, 51 bytes f=lambda n,k=2:n<3or k<n and f(k)*f(n-k-2)+f(n,k+1) Try it online! Simplifies the formula a bit: $$a(n) = \sum_{k=2}^{n-1} a(k)\cdot a(...
xnor's user avatar
  • 145k
23 votes

Cantor's unspeakable numbers

Python 2, 77 75 74 70 bytes Thanks to @MartinEnder for suggesting the limit of 9e5 which enderd up working after a change.Thanks to @mschauer for suggesting an ...
PurkkaKoodari's user avatar
22 votes

Arbitrary-length currying

Haskell (GHC), 118 bytes This is 98 bytes for the code and 20 bytes for the GHC compiler flag -XFlexibleInstances, which enables a type system extension. ...
Zgarb's user avatar
  • 42.7k
21 votes

Exponentially Slimy Programming: Stacking Minecraft Slimes

MATL, 77 76 74 bytes :"')^.,9&Xze`}+.E=p'F3ZaQ8e@qWt3$Y"G@-W1X"]&h[OOO;11 17E]5*29 7U24hhE&vEYG The code works in this commit, which is ...
Luis Mendo's user avatar
  • 105k
21 votes

The best base is 10... Let's reach it!

Mathematica, 56 bytes #//.x_/;(b=Max[d=IntegerDigits@x]+1)<11:>d~FromDigits~b& Try it online! (Using Mathics.) I thought I'd check out what the ...
Martin Ender's user avatar
20 votes

Hofstadter H-sequence

Haskell, 23 22 bytes f 0=0 f n=n-f(f$f$n-1) Simply uses the definition of the sequence. f(f$f$n-1) is equivalent to ...
Doorknob's user avatar
  • 71.5k
20 votes

Nesting list with a value repeated `n` amount of times

Python 2, 33 30 bytes -3 bytes thanks to @xnor lambda n,v:eval('[v,'*n+']'*n) Try it online!
dingledooper's user avatar
  • 22.7k
19 votes

One More Program and I'm Out!

Jelly, 2 bytes Ṿ¡ Try it online! ...
hyper-neutrino's user avatar
  • 42.4k
19 votes

One More Program and I'm Out!

JavaScript (ES6), 47 44 bytes Saved 3 bytes thanks to @HermanLauenstein Takes input in currying syntax (n)(s). ...
Arnauld's user avatar
  • 193k
18 votes
Accepted

Is there a way of shortening fat-arrow functions?

Use Recursion I've found that recursion is (almost) always shorter than eval+for. The general way to convert from for to eval ...
Downgoat's user avatar
  • 29k
17 votes

Arbitrary-length currying

Python 2, 42 41 36 bytes This solution will never have an overflow, since Python supports arbitrary-precision integers. Zero is the "special value". ...
mbomb007's user avatar
  • 23.4k
17 votes

Многочлены Чебышёва (Chebyshev Polynomials)

Mathematica, 15 bytes #~ChebyshevT~x& Of course, Mathematica has a builtin. If an alternative input form is allowed (10 bytes): ...
JungHwan Min's user avatar
  • 13.8k
16 votes

The Ackermann function

Binary lambda calculus, 54 bits = 6.75 bytes Hexdump: 00000000: 1607 2d88 072f 68 ..-../h Binary: ...
Anders Kaseorg's user avatar
15 votes

Exponentially Slimy Programming: Stacking Minecraft Slimes

Dyalog APL, 118 113 bytes ('P3',⌽∘⍴,255,∊)(3↑(116 196 96)(110 170 90))[⊃,/i{⊃⍪/⍵⍴⊂⍺⌿⍺/8 8⍴∊22923813097005 926134669613412⊤¨⍨⊂32⍴3}¨⌽i←2*⍳⎕] assuming ...
ngn's user avatar
  • 15.3k
14 votes

Arbitrary-length currying

Mathematica, 25 bytes f[x_]@y_=f[x+y] f[x_][]=x Try it online! (Using Mathics.) It's possible to do three bytes less by porting the JavaScript answer, but I ...
Martin Ender's user avatar
14 votes

Arbitrary-length currying

C, 62 58 bytes, borderline competing Saved 4 bytes thanks to Kevin! (Still not removing typedef because it's something needed in order to be called.) ...
Conor O'Brien's user avatar
14 votes

Многочлены Чебышёва (Chebyshev Polynomials)

Octave, 39 bytes @(n)round(2^n/2*poly(cos((.5:n)/n*pi))) Try it online! Explanation cos((.5:n)/n*pi) builds a vector with the ...
Luis Mendo's user avatar
  • 105k
14 votes

Pointlessly make your way down the alphabet

C (gcc),  58  56 bytes Saved 2 bytes thanks to @KritixiLithos c;f(char*s){while(c=c&&putchar(c>96?c:10)^10?c-1:*s++);} Try it online!
Arnauld's user avatar
  • 193k
14 votes

Pointlessly make your way down the alphabet

Haskell, 26 24 bytes -2 bytes thanks to FrownyFrog. map(\i->reverse['a'..i]) Try it online! Pointless (or pointfree :P) for you.
totallyhuman's user avatar
  • 17.2k
14 votes

Pointlessly make your way down the alphabet

Malbolge20 and Malbolge Unshackled polyglot, around 2MB, 107KB compressed. Alright. I spent around 30 minutes on this answer (current record). It's really optimal answer. Albeit not so fast and not ...
Kamila Szewczyk's user avatar
12 votes

Exponentially Slimy Programming: Stacking Minecraft Slimes

JavaScript (ES7), 326 327 bytes ...
insertusernamehere's user avatar
11 votes

Is there a way of shortening fat-arrow functions?

Abuse eval. It's simple. Instead of: f=n=>{for(i=c=0;i<n;i++)c+=n;return c} Use ...
Conor O'Brien's user avatar
11 votes

Многочлены Чебышёва (Chebyshev Polynomials)

Pari/GP, 12 bytes Yes, a builtin. Shorter than Mathematica. polchebyshev Try it online! Without builtin: Pari/GP, 34 bytes ...
alephalpha's user avatar
  • 48.5k
11 votes

1, 2, 4, 8, 16, ... 33?

05AB1E, 14 13 11 bytes $ƒˆ¯Âø¨¨¨PO Try it online! Outputs the nth element, 0-indexed. ...
Grimmy's user avatar
  • 15.7k
10 votes

Cantor's unspeakable numbers

Perl, 47 46 41 39 bytes Saved 5 bytes thanks to @Dada say$_=$_%7*!/7/?$_:$a[$b++]for@a=1..1e6 Try It Online! TIO Nexus, now with Perl support! This will truncate ...
Gabriel Benamy's user avatar
10 votes

The best base is 10... Let's reach it!

Java 8, 172 166 163 152 151 140 138 116 114 99 bytes ...
Kevin Cruijssen's user avatar
10 votes

Многочлены Чебышёва (Chebyshev Polynomials)

Haskell, 62 bytes t n|n<2=1:[0|n>0]|x<-(*2)<$>t(n-1)++[0]=zipWith(-)x$0:0:t(n-2) Try it online! flawr saved a byte.
lynn's user avatar
  • 68.8k
10 votes

One More Program and I'm Out!

sh + coreutils, 31 bytes yes exec sed 1d \$0|sed $1q;cat Takes n as a command-line parameter and ...
Neil's user avatar
  • 172k

Only top scored, non community-wiki answers of a minimum length are eligible