[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

RE: [FWP] Can it be funner?



> I believe the fun factor is slightly higher in this version;
> 
> $_="aaabbbbccaaajjjcccooaaabbbbjjjjjaeefcccooaaabbbbjjaajj";
> 
> for($n=0;/(.{$n,}).*\1/;$n=length($1)+1){$s=$1;};
> 
> print "$s\n";
> 
> It could probably do with some further obfuscation!

I can't top this; heck, I can't even understand it.  This is the best I
could do; it has the (dubious) advantage of sucking out *all* repeated
substrings:

$_ = 'aaabbbbccaaajjjcccooaaabbbbjjjjjaeefcccooaaabbbbjjaajj';
do{ /(.+).*\1/g;push @repeats, $1;pos = ++$pos; } while $pos < length;
print +(sort { length $b <=> length $a } @repeats)[0];

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org