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

Santa Hole 5 (wc.pl) Post Mortem

Thread Next
From:
Andrew.Savige
Date:
December 6, 2001 15:36
Subject:
Santa Hole 5 (wc.pl) Post Mortem
Message ID:
694BB7191495D51183A9005004C0B05408DFD7@ir-exchange-srv.ir.com.au
This hole was one by Japhy with his first post in the opening
hours of the game.

Like hole 2, this proved very frustrating with all attempts
to improve on printf failing. BooK, in particular, made repeated
heroic attempts:

"My wc.pl is 21, but uses printf. I tried many things to get rid of
printf, but all of them ended up being longer...

Here they are (the first ' ' 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

These are the longuest I did. All my shorter ones use printf."

*** Hole 5 (wc.pl) ***
--- Tim Ayers ------------------------ 21
#!/usr/bin/perl
printf"%010d\n",$.,<>
--- Ala Qumsieh ---------------------- 21
#!perl
printf"%010d\n",$.,<>
--- Scott Wessels -------------------- 21
#!perl
printf"%010d\n",$.,<>
--- BooK ----------------------------- 21
#!/usr/bin/perl
printf"%010d\n",$.,<>
--- Ronald J Kimball ----------------- 21
#!/usr/local/bin/perl
printf"%010d\n",$.,<>
--- Robin Houston -------------------- 21
printf"%010d\n",$.,<>
--- Rick Klement --------------------- 21
printf"%010d\n",$.,<>
--- Rick Delaney --------------------- 21
#!/usr/bin/perl
printf"%010d\n",$.,<>
--- Eugene van der Pijll ------------- 21
printf"%010d\n",$.,<>
--- me-01@ton.iguana.be -------------- 21
#!/usr/bin/perl
printf"%010d\n",$.,<>
--- Piers Cawley --------------------- 21
#!/usr/bin/perl -lp
$#='%010g'}{$_=$.
--- Michael G Schwern ---------------- 21
#!/usr/bin/perl
printf"%010d\n",$.,<>
--- Japhy ---------------------------- 21
#!/usr/bin/perl
printf"%010d\n",$.,<>
--- Jerome Quelin -------------------- 21
#!/usr/bin/perl
printf"%010d\n",$.,<>
--- Karsten Sperling ----------------- 21
#!/usr/bin/perl
printf"%010d\n",$.,<>
--- Tony Payne ----------------------- 21
#!/usr/bin/perl
printf"%010d\n",$.,<>
--- Yanick --------------------------- 21
#!/usr/bin/perl
printf"%010d\n",$.,<>
--- Keith C Ivey --------------------- 22
#! /usr/bin/perl -lp
}{$_=7e10+$.,s$.$$
--- Evan A Zacks --------------------- 22
#!/usr/bin/perl -lp
}{printf"%010d",$.
--- Jonathan E Paton ----------------- 22
#!/usr/bin/perl -pl
}{printf"%.10d",$.
--- Ian Boreham ---------------------- 23
#!/usr/bin/perl
[<>];printf"%.10d\n",$.
--- Michael Lambert ------------------ 23
[<>];printf"%010d\n",$.
--- Brad Greenlee -------------------- 23
[<>]&printf"%010d\n",$.
--- Richard Proctor ------------------ 23
[<>];printf"%010d\n",$.
--- Mark Suter ----------------------- 23
#!/usr/bin/perl -n
}{printf"%010d\n",$.
--- Damian James --------------------- 23
#!/usr/bin/perl -n
}{printf"%010d\n",$.
--- Csaba Raduly --------------------- 23
#!perl -n
}{printf"%010d\n",$.
--- Vladi Belperchinov-Shabanski ----- 24
#!/usr/bin/perl
printf"%010d\n",$_=@_=<>
--- Dave O'Neill --------------------- 24
#!/usr/bin/perl
@_=<>;printf"%.10d\n",$.
--- Simon Drabble -------------------- 24
@a=<>;printf"%010d\n",$.
--- Anthony J Breeds-Taurima --------- 24
#!/usr/bin/perl
[<>];printf"%0.10d\n",$.
--- Ian Phillipps -------------------- 25
#!/usr/bin/perl
printf"%010d\n",(@x=<>)+0
--- Josh Shulz ----------------------- 25
#!/usr/bin/perl
@a=<>;printf "%010u\n",$.
--- Aaron D Marasco ------------------ 26
#!/usr/bin/perl -n
END{printf"%010d\n",$.}
--- Zed Lopez ------------------------ 26
#!/usr/bin/perl -n
eof..printf"%010d\n",$.

--- anonymous ------------------------ 22
#!perl -pl
}{printf"%010d",$.
--- anonymous ------------------------ 23
#!perl -n
}{printf"%010d\n",$.
--- anonymous ------------------------ 23
#!/usr/bin/perl -pl
}printf"%010d",$.;{
--- anonymous ------------------------ 23
#!/usr/bin/perl
[<>];printf"%010d\n",$.
--- anonymous ------------------------ 24
#!/usr/bin/perl -n
}printf"%010d\n",$.;{
--- anonymous ------------------------ 24
#!/usr/bin/perl
@_=<>;printf"%.10d\n",$.
--- anonymous ------------------------ 24
@_=<>;printf"%010d\n",$.
--- anonymous ------------------------ 25
#!/usr/bin/perl
printf"%010d\n",0+@{[<>]}
--- anonymous ------------------------ 26
#!/usr/bin/perl
@a=<>;printf("%010u\n",$.)


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