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

Re: Just chipping in...

Thread Previous | Thread Next
From:
Tuomo Salo
Date:
November 19, 2007 10:40
Subject:
Re: Just chipping in...
Message ID:
4741B154.7040300@plenware.fi
-----BEGIN PGP SIGNED MESSAGE-----

- From the keyboard of Phil Carmody (2007-11-15 15:05):
> I saw this on sci.math, and thought "one liner" ;-)

While I could not squeeze this down to a one 80 char line, there is only
one line that does not begin with a # :-)

#!perl -l
$\=~s#(.*)\n#"$1(\n"x($1=~y/(//<$a)."$1)\n"x($1=~y/)//*2<$_-1)
#gefor 1..2*($a=pop);print


I tried to do the generation by hand, implemented that method as a
regex, and polished (or should I say disfigured) the result with a
couple of standard golfing tricks. Notice the lack of escaped parens,
btw :-)

There are probably a couple of mrmagoos there, at least you could lose
a couple of chars (along with any perceived one-linerness) by replacing
the "\n":s with literal newlines.

Cheers,

  -bass

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQB1AwUBR0GxVPbPZUB64qcJAQFFFAL/ejNBEfzY9+PwNSS+EtakB+UC7RpfzBu5
FmVwYQ8JXoEiCPjuSfqEA+D6I5qhioNhQsuMOoG3YEbaWbhjRuEpTcNmdIhbDBi1
g8sRXE1rOlCO+wgR4ZVUjXoROrhj4AoN
=4jPH
-----END PGP SIGNATURE-----

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