develooper Front page | perl.fwp | Postings from February 2002

TPR0: the leaderboard...

Thread Next
From:
Jerome Quelin
Date:
February 11, 2002 02:24
Subject:
TPR0: the leaderboard...
Message ID:
<3c679bb63cbcbdfe@mel-rta2.wanadoo.fr>(added by mel-rta2.wanadoo.fr)
Hello,

Here is the leaderboard.

Veterans
--------
35	BoB # Based on Ralph solution: Ralph, you can achieve it!
50	Ralph
51 ^	Amir Karger
52	Ben Tilly
53	Daniel Pfeiffer
54	Xiang Qi
55	Thomas G. Rokicki
60	Hrafnkell F Hlodversson
60	Yaakov Belch
63	Rick Klement
67	John Wells
69	Jon Coulter
69	Mtv Europe
69	Joaquin Ferrero
70 ^	Jarkko Hietaniemi
70	Kristoffer Lunden
71	Sam Sargeant
73	F.Xavier Noria
73	Colin Meyer
75	Stas Bekman
76	darin
78	Albert Dvornik
79	Les Peters
81	Kostas Pentikousis
81	Erik Cunningham
84	Alain Trembleau
90	Jay Lawrence
91	Dave Tallman
96	Mansoor Sirinathsingh
112	Jason Rush
127	Brett DiFrischia
128	Eric Brown
147	Ted Logan
153	Dave Noble
161	Kurt Telep
364	Charles Reace

Beginners
---------
71 ^	Jason Purdy
112	James Richardson


Did not fulfill requirements:
- Arnaud Assad
- Jack Diederich
- Freyr Harfnkell
- Chas Owens
- Max Fedchenko
- Clive Holloway
- Daniel Allen
- David Corbin
- John Trammel
- Zaphod Beeblebrox
- Ming Wang
- Phil Jach
- Jason Kost
- Yanick

Daniel Pfeiffer submitted a 36 chars solution, but I discarded it since you 
can't rely on executables other than perl, even the shell.


I remember you the fixed rules:
- Number is to be taken as first arg of the script.
- You can assume input as [0-9A-Z] (ie, no lowercase).
- No stderr output.
- STDOUT must be properly newline terminated.
- Newlines in the script ok.
- perl 5.6.1
- only use the perl executable, but ok to call your own program
- standard modules
- return code does not matter
- deadline on 15/02/2002 12:00 CET

In order to apply these rules, I slightly modified your submissions to meet 
the requirements (ie, add a "$_=pop", or a " -l" flag, etc.). If the 
modifications were too important, your submission is counted as "not ok".

Submit entries to golf@theperlreview.com
You will find a (rough) test program that you will launch like this:
$ ./tpr0.pl <name-of-your-script>

__BEGIN__
#!/usr/bin/perl
use strict;
sub GolfScore {
   my $script = shift;
   local ($_, *FF);
   open(FF, $script) or die "could not open $script: $!";
   my $golf = -1;     # your free last newline
   while (<FF>) {
       s/\n?$/\n/;
       $golf-- if $. == 1 && s/^#!.*?perl//;
       $golf += length;
   }
   close(FF);
   return $golf;
}
my $script = shift;
print "You shot a round of ", GolfScore($script), " strokes\n";
my $a;
$a = `perl $script 1 2>err`;
-s "err" and die "oops, you wrote to STDERR\n";
$a  ne "1\n" and die "expected:\n--\n1\n--\ngot:\n--\n$a"."--\n";
$a = `perl $script 1B 2>err`;
-s "err" and die "oops, you wrote to STDERR\n";
$a  ne "47\n" and die "expected:\n--\n47\n--got:\n--\n$a"."--\n";
$a = `perl $script ZZZ 2>err`;
-s "err" and die "oops, you wrote to STDERR\n";
$a  ne "46655\n" and die "expected:\n--\n46655\n--\ngot:\n--\n$a"."--\n";
print "Hooray, you passed!\n";
__END__

Thank you for submitting.

Jerome
-- 
jerome.quelin@insalien.org

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