33
votes
Pointlessly make your way down the alphabet
Dyalog APL Extended, 4 bytes
⌽∘⍳¨
Try it online!
...
28
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(n-...
27
votes
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!
19
votes
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).
...
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!
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.
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 ...
12
votes
1, 2, 4, 8, 16, ... 33?
Perl 6, 44 bytes
{1,1,1,1,{sum @_[2..*]Z*@_[@_-4...0,0]}...*}
Try it online!
Anonymous code block that returns a lazy infinite sequence of values. This pretty ...
11
votes
1, 2, 4, 8, 16, ... 33?
05AB1E, 14 13 11 bytes
$ƒˆ¯Âø¨¨¨PO
Try it online!
Outputs the nth element, 0-indexed.
...
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 ...
10
votes
Accepted
Nesting list with a value repeated `n` amount of times
05AB1E, 3 bytes
F‚Ù
Try it online.
Explanation:
...
9
votes
What's left after repeatedly removing palindromes
Nekomata, 14 bytes
ʷ{;;$ƀ=tŁ¿,}aş
Attempt This Online!
Extremely slow for long inputs that contain many palindromes.
...
8
votes
Pointlessly make your way down the alphabet
PowerShell, 37 28 bytes
-9 bytes thanks to mazzy
$args|%{-join($_..'a'-le$_)}
Try it online!
Takes input via splatting and uses char ranges introduced in PS v6. ...
8
votes
Nesting list with a value repeated `n` amount of times
Python, 34 bytes
f=lambda x,n:n and[x,f(x,n-1)][:n]
Attempt This Online!
Thanks to loopy walt for this one.
Old answers:
Python, 36 bytes
f=lambda x,n:[x][n>1:]or[x,f(x,n-1)]
Attempt This Online!
...
8
votes
Nesting list with a value repeated `n` amount of times
Vyxal r, 4 bytes
(⁰"U
Try it Online!
The joys of golfing language :)
Explained
...
7
votes
7
votes
Different combinations possible
Python, 40 bytes
f=lambda n,k:k<2or~-n*n*f(n-1,k-1)/~-k/k
Try it online!
Uses the recurrence \$a_{n,1} = 1\$, \$a_{n,k} = \frac{n(n-1)}{k(k-1)}a_{n-1,k-1}\$.
7
votes
1, 2, 4, 8, 16, ... 33?
JavaScript (ES6), 42 bytes
A port of xnor's solution.
0-indexed.
f=(n,k=2)=>n<3||k<n&&f(k)*f(n+~++k)+f(n,k)
Try it online!
JavaScript (ES6), 83 ...
7
votes
1, 2, 4, 8, 16, ... 33?
Haskell, 49 43 39 bytes
a n=max(sum[a k*a(n-2-k)|k<-[2..n-1]])1
Try it online!
For n<3 the ...
7
votes
1, 2, 4, 8, 16, ... 33?
Wolfram Language (Mathematica), 36 33 bytes
Sum[#0[#-i]#0@--i,{i,4,#}]~Max~1&
Try it online!
1-indexed.
The 2-indexed sequence is 2 bytes shorter: ...
7
votes
1, 2, 4, 8, 16, ... 33?
05AB1E, 17 16 13 bytes
4Å1λ£λ¨Â¦¦s¦¦*O+
Not shorter than the existing 05AB1E answer, but I wanted to try the recursive functionality of the new 05AB1E version as ...
7
votes
Pointlessly make your way down the alphabet
Python 3, 65 bytes
lambda s:print([''.join(map(chr,range(ord(c),96,-1)))for c in s])
Outputs a list of strings as clarified in @Arnauld's comment.
If we could ...
7
votes
Pointlessly make your way down the alphabet
Sed (with -r switch), 65 61 60 59 characters
s/./&zyxwvutsrqponmlkjihgfedcba \n/g
s/(.).*\1/\1/gm
s/ //g
Thanks to:
...
7
votes
Visualize a Recursive Acronym
APL (Dyalog Extended), 33 32 bytes
-1 byte thanks to Bubbler.
Anonymous infix lambda. Takes count as left argument and string as right argument.
...
7
votes
7
votes
Unicode T-square
JavaScript (ES6), 108 bytes
Returns an array of strings, with 0123 instead of ┌┐└┘.
...
7
votes
Nesting list with a value repeated `n` amount of times
Proton, 25 bytes
n=>v=>((a=>[v,a])*n)([v])
Try it online!
...
7
votes
Number of cigarettes that can be made from a given number of butts
JavaScript (ES6), 10 bytes
Unless I'm missing something, this boils down to:
n=>~-n/3|0
Try it online!
Or 9 bytes with BigInts.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
recursion × 41code-golf × 38
math × 10
arithmetic × 7
sequence × 5
number × 4
tips × 3
graphical-output × 3
fractal × 3
string × 2
array × 2
decision-problem × 2
base-conversion × 2
interpreter × 2
counting × 2
balanced-string × 2
ascii-art × 1
number-theory × 1
combinatorics × 1
random × 1
game × 1
fastest-code × 1
python × 1
optimization × 1
javascript × 1