develooper Front page | | Postings from January 2007

Re: simple golf for fun

Thread Previous | Thread Next
Phil Carmody
January 17, 2007 04:13
Re: simple golf for fun
Message ID:
--- Ton Hospel <> wrote:
> -p0 s/\G(.*)(.*
> )(?=\1.\2|$)//g
> This should be about as efficient as a simple regex
> approach gets. It's also the shortest yet :-)
> It outputs starting from the first line that can't
> be extended. No output means all lines work.

Excellent! That's more useful output too!
31 chars for the alien!

There seemed to be a bug in previous versions (though to be honest not a
serious one, one that could be considered as inviting a loosening of the
specification) - if you added an extra blank line between two real lines, it
would still pass. Funnily enough, my log file did have such a blank line.
It also crashed on my 2500-line file. Your current one doesn't crash.

Many thanks, all!

()  ASCII ribbon campaign      ()    Hopeless ribbon campaign
/\    against HTML mail        /\  against gratuitous bloodshed

[stolen with permission from Daniel B. Cristofani]

Want to start your own business?
Learn how on Yahoo! Small Business.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About