Help for this page

Select Code to Download


  1. or download this
    sub canonical {
    my(@a,$i,%c,$c)=pop=~/./g;$c.=$c{$_}||=$a[$i++]for pop=~/./g;$c
    }
    
  2. or download this
    sub canonical {
    ($_,$a,%h)=@_;s!.!$h{$&}||=($a=~/./g,$&)!ge;$_
    }
    
  3. or download this
    sub canonical {
    ($_,$a,%h)=@_;s!.!{$h{$&}=~s+^\z+$a=~/./gs,$&+ge}$h{$&}!gse;$_
    }