Skip to main content
5 of 6
added 472 characters in body

dc, 72 bytes

[3Q]sq2?dsa^1+2/dsusk[Ola^/O%plk1-dsk1>q]sp1[d5r^dOla^<psz1+d4/lu>t]dstx

0-based indexing.

Try the dc program online!


The dc code can be turned into a Bash solution:

Bash + GNU utilities, 96 77 75 bytes

u=$[(2**$1+1)/2]
dc -e "[O$1^/O%p]sp1[d5r^dO$1^<psz1+d4/$u>t]dstx"|head -$u

Try the Bash version online!