BWT by nn

$(i=FS=_)=$0{for(N=NF;i<N;o=p=_){for(j=i;j<N+i;)o=o$(j++%N+1)
for(j=++i;--j&&o<a[j];)a[j+1]=a[j]
a[j+1]=o}for(n=j=N;j;n=$0~v?j:n)p=substr(v=a[j--],N)p
print n,p}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page