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

Re: [FWP] longest substring with unique characters



At 06:03 AM 1/19/01 -0800, Daniel Chetlin wrote:
>Oh, and for the ObGolf category:
>
>   perl -ple'my$m;do{local%s;/(((.)(?(?{$s{$3}++})(?!)))+)/g or$i=-1;
>             $m=$1 if length$1>length$m}while pos=++$i;$_=$m'
>
>(114 characters, including `perl' and the switches)
>
>This one requires 5.6+ and only gets the first longest unique string.

If I golf my last one, I get

perl 
-nle'do{$s="";/((.+?)(??{push@{$l[length$2]},$2;$s.=$2;"[$s]"}))/}while 
s/.//;print"@{$l[-1]}"'

which is 100 characters and does all longest unique strings.  But I have a 
feeling Abigail can top that in short order...

--
Peter Scott
Pacific Systems Design Technologies


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe