hi all,
hopefully this hasn't been done here before - sorry if it has
@p=sort a @a=split//,"Just Another Perl Hacker!";while(f(@p)){{@t=@p;@ +m= sort a@p[@w];$t[$_]=pop@m for@w;redo if f(@t)>=f(@p)}print@p=@t,$",f(@ +p) ,$/}sub p{$c=0;push@{$l{$_}},$c++for@a}sub f{@w=$f=$d=$c=p;map{$f+=(($ +z= (shift@{$l{$_}})-$c++)**2)**.5;$w[$d++]=$c-1if$z}@_;$f}sub a{rand cmp. +5}
Hope you like it.
Alex
ps. the numbers are the "fitness" of that generation of string....