BWT by daira

<?for(;$a=trim(fgets(STDIN));print"$n $o
"){$l=strlen($a);$c=$a.$a;$b=null;for($i=$l;$i--;sort($b))$b[]=substr($c,$i,$l);for($o='';$b[++$i];$o.=$b[$i][$l-1])if(!strcmp($b[$i],$a))$a.=$n=$i;}

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

download

return to the top page