develooper Front page | perl.golf | Postings from January 2007

Re: simple golf for fun

Thread Previous | Thread Next
From:
perl-golf
Date:
January 16, 2007 10:47
Subject:
Re: simple golf for fun
Message ID:
eoj6jf$rgr$1@post.home.lunix
In article <44740.40399.qm@web25409.mail.ukl.yahoo.com>,
	Phil Carmody <thefatphil@yahoo.co.uk> writes:
> This is a real world task which can be solved in a couple of lines. 
> Which makes me think that you guys can do it in about half a line!
> 
> The simple version of the task is to verify that each line of a file is the
> insertion of one character somewhere (maybe at the start or the end) into the
> prior line.
> 
> So
> <<<
> 1
> 12
> 132
> x132
>>>>
> would be accepted, but
> <<<
> 1
> 12
> 132
> alien132
>>>>
> would not be accepted.

Regex is always nice:
-p0 $_ x=/^((.*)(.*)
(?=\2.\3
|$))*$/

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About