On Tue, Apr 16, 2002 at 09:39:28PM +0000, Ton Hospel wrote:
> In article <[EMAIL PROTECTED]>,
>       Mtv Europe <[EMAIL PROTECTED]> writes:
> > I'm sorry for flooding.
> > 
> >>> -p @$=a..z;pop@$ while@$>3&&!/@$[-4..-1]/x;$_ x=@$>3
> >> that's better -
> >> -p @$=a..z;pop@$ until@$<4||/@$[-4..-1]/x;$_ x=@$>3
> > 
> > -p @$=a..z;1until/@$[-4..-1]/x|!--$#$;$_ x=@$>3
> Near the end it's going to match anyways, so you can do:
> -p @z=a..z;$#z--until/@z[-4..-1]/x;$_ x=@z>3

I played around a bit, and only got so far:
-p $"="|";$_ x=/@{[join('',a..z)=~m!(?=(....))!g]}/

googling for it I found Archives at
<URL:http://www.bumppo.net/lists/fun-with-perl/2000/08/threads.html>
which contains a few interesting solutions:

I have to admit, I don't understand why this one works:

-n print if join("",a..z)=~join"|",/(?=(....))/g,_

next one produces false positives with "xyzaa" "yzaaab" and "zaaabac":

-n /.(??{($a=$&)++;$a++.$a++.$a})/&&print

and, afaics the winning one:

-n /(.)((??{chr 1+ord$+})){3}/&&print

which can (with todays golf knowledge) be shortened to:

-p $_ x=/(.)((??{chr 1+ord$+})){3}/

The other variant:

-p $_ x=/(.)((??{++($p=$+)})){3}/

does not work, and I'm not sure why, because 

-p $_ x=/(.)((??{++($p=$+)x1})){3}/

does again work :)

CU,
    Sec
-- 
Consider the need for having to type "www.domain.name" a little IQ test
that you have to take before you can access my web site.'     -- Wietse

Reply via email to