develooper Front page | perl.fwp | Postings from December 2001

Re: Santa Hole 5 (wc.pl) Post Mortem

Thread Previous | Thread Next
From:
Philippe 'BooK' Bruhat
Date:
December 7, 2001 10:38
Subject:
Re: Santa Hole 5 (wc.pl) Post Mortem
Message ID:
Pine.LNX.4.21.0112071922500.2932-100000@rose.home.bruhat.net
On Fri, 7 Dec 2001, BooK wrote:

> En réponse à "Keith C. Ivey" <kcivey@cpcug.org>:
> 
> > I'm surprised no one submitted anything with 0 x10, but I
> > guess those always end up too long.
> 
> Well, I tried a lot of thing with x10, like $-x10, because I wanted really
> hard to use the magic features of ++ on strings, but they were all too long.
> 
> When I get home in a few hours, il post all my tests for wc.pl, in decreasing
> length... (some of the longuest for found very late -- had to test others ways
> to do it)

Here they are (the first space marks the end of the command-line
switches):

-n END{print$a,$/}BEGIN{$a='00'x5}++$a # 38
-n BEGIN{$a=$-x10}$a++;END{print$a,$/} # 38
-n INIT{$a=$-x10}$a++;END{print$a,$/}  # 37
-lp0 $_=y/\n//;$_=$-x(- y///c%10).$_   # 36
-lp0 $_=substr$-x9 .y/\n//,-10         # 30
-ln0 printf"%010d\n",$a=y/\n//         # 30
@a=(<>);printf"%010d\n",1+$#a          # 29
-ln0 printf"%010d\n",y/\n//+0          # 29
-lp0 $_=sprintf"%010d",y/\n//          # 29
@a=<>;printf"%010d\n",$#a+1            # 27
-ln0 printf"%010d\n",y/\n//            # 27
-n0 printf"%010d\n",y/\n//             # 26
-n END{printf"%010d\n",$.}             # 26
printf"%010d\n",$a=@{[<>]}             # 26
printf"%010d\n",0+@{[<>]}              # 25
printf"%010d\n",$.,<>                  # 21

For the record, I also tried this, which doesn't work if the file is
exactly one (1) line long:

-lp0 $_=$-x(10-.43*log($_=y/\n//)).$_  # 37

Since it doesn't work on one-liners for mathematical reasons, I didn't try
any further...

Erm, OK, I just tried further and got here:

-ln END{print$-x(10-.43*log$.).$.}     # 34


Here are my tests for head.pl:

print+(<>)[0..9]                       # 16
-p last if$.>10                        # 15
-p $.>10&&last                         # 14
-p $.<11||last                         # 14
-p $.-11||last                         # 14
-p $.^11||last                         # 14
-p /11/&&last                          # 13 cheat!

And then I looked over Piers shoulder...

-- 
 Philippe "BooK" Bruhat

 History is made by the winners and written by those with the loudest voices.
                                    (Moral from Groo The Wanderer #10 (Epic))


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