develooper Front page | | Postings from January 2007

Re: simple golf for fun

Thread Previous | Thread Next
January 17, 2007 05:10
Re: simple golf for fun
Message ID:
In article <>,
	Daniel Tiefnig <> writes:
> If you're free to output whatever you want on mismatch, you can also
> just omit the "\G".
> -p0 s/(.*)(.*
> )(?=\1.\2|$)//g
> Will print all lines that preceed invalid changes. (As requested!) One
> can create files that will make some problems, though. If a line does
> not add at least one character, strange things may happen. But I think
> it will always output something.
> And until someone proves the contrary, I consider this being the
> shortest solution so far. :o)

Correct. It outputs at least the first char of a non-extendable line or
the newline after it if that line is empty.

By the way, what these programs don't check is if the first line is a
single character. The challenge statement is unclear on if the first
line should be seen as an extension of a ghost empty line or not.

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