Skip to content

Instantly share code, notes, and snippets.

@fjyuu
Created November 13, 2012 17:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fjyuu/4067055 to your computer and use it in GitHub Desktop.
Save fjyuu/4067055 to your computer and use it in GitHub Desktop.
Code Golf of Burrows-Wheeler Transform
#!perl -pl
$n=index$_,"[";y/[]//d;@c=split//;@i=sort{$c[$a]cmp$c[$b]}0..$#c;$_=join"",map{$c[$n=$i[$n]]}@c
#!perl -palF""
@i=sort{"@F[$a..$#F] @F[0..$a-1]"cmp"@F[$b..$#F] @F[0..$b-1]"}0..$#F;$_=join"",map{$_--?"$F[$_]":"[$F[$_]]"}@i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment