This is your chance to get even by playing a brand new two-hole golf course -- drawing its name from its signature opening hole.
The game starts now and ends exactly five days from now. This game borrows heavily from its predecessors, the fwp Santa golf game and Ton's ircnet companion described at http://a108.bauhuette.haw-hamburg.de/golf/challenge.html. A test program, teven.pl, and embedded below, is provided to help screen entries. Any program that passes the test program should be submitted. Especially if you suspect your program unsound, but it passes the test program, please submit it anyway! That is how we identify bugs in the test program. When you submit your entry -- to me only -- please state the golf score reported by teven.pl. I suggest you simply embed your two programs in the mail message. Please take care to not accidentally post any solutions to the fwp mailing list!! Do not publish your solutions anywhere. That will spoil the game, as your solutions are meant to be secret. All solutions will be published at the end of the game. To add a little excitement, a current leaderboard will be posted to fwp at least daily. Beginners are encouraged to enter and there will be a separate leaderboard for them. If you are a beginner, please say so when submitting your entry. The leaderboard will show total score only. However, exactly 24 hours before the game ends, the lowest available score for both holes will be published. Also, the current hole leaders (but not their score) will be continuously updated. I will also use Ton's BoB (best-of-breed) innovation in this game. If there is a tie, well, it is a tie. Due to time differences around the world and differing work and family commitments, there is no fair way to break ties. Oh, and don't forget the Supremely Unorthodox Prize awarded to the most original and artistic solution. I know there are some specialist obfuscators out there (hello BooK;-) so I suppose they would be early favourites for this prize. It is recommended that you run the test program under Unix or Windows NT/2000. However, teven.pl should also run under Windows 95/98, albeit with a warning that it cannot detect what is written to stderr. You must name your programs even.pl (hole 1) and gs.pl (hole 2), and put them in the same directory as the test program, teven.pl. That done, run the test program: perl teven.pl. to verify that your entry is valid. The scoring rule is the same as that used in Ton's recent game. Multiple lines are permitted, with a newline counting as one stroke. Though the #! line is not counted, the options themselves (if any) are counted, including the leading space and -. I will try to describe the semantics of each hole below. If you are in any doubt about the semantics, please study or run the test program to see what it accepts and rejects. ----------------------------------------------------------- General Rules that apply to both holes Your program should work on Perl 5.6.1. You may use any of the standard 5.6.1 core modules. You may use only the Perl executable; other external commands are banned. Both holes read from a single input file given as the first command line argument. The input file may be assumed to exist. The input file may be assumed to be non-empty. The input file may be assumed to comfortably fit into memory. The input file may be assumed to contain no binary zeros. Like Ton's game, you may assume ASCII as the character set but you may not use Unicode-specific semantics. The program return code does not matter. ----------------------------------------------------------- Hole 1 -- Get Even (even.pl) Your program reads from a single input file and writes to stdout; you are not permitted to write anything to stderr. You may assume that the input file is properly newline- terminated. Similarly, your program must properly newline-terminate everything it writes. The input file is a text file of words, one word per line. Each word consists of [a-z] only. Each input line consists of the word only, with no leading or trailing whitespace, and no empty lines. A vowel is defined as a,e,i,o,u,y. Note the 'y'. You must write to stdout all words that satisfy all of the following conditions: a) are on an even line number in the input file b) have an even word length c) contain an even number of each and every distinct vowel in the word You must write the matching words to stdout in the same order as they appear in the input file. For example, the following words (so long as they are on an even line number) should be written: doctor length=6, 2 o's (ok) kangaroo length=8, 2 a's, 2 o's (ok) while the following words should not be written: unusable length=8 (ok), 2 u's (ok), 1 a (not ok), 1 e (not ok) santa length=5 (not ok), 2 a's (ok) You may not make arbitrary assumptions about the content of a word. For example, you may not assume that every word must contain at least one vowel, or that each word contains a maximum of 9 vowels, or that all words are less than 30 characters in length, say. ----------------------------------------------------------- Hole 2 -- Golf Scorer (gs.pl) This is a primitive "golf scorer" program. You might use it to remove all newlines from a long golf program while writing its approximate golf score to stderr. On this hole, you may not assume that the input file is properly newline terminated. That is, the last line in the input file may or may not contain a newline. This program must write to stdout all characters in the input file except for newlines. It must also write to stderr the count of the total number of non-newline characters in the input file. You must properly newline terminate the number that is written to stderr. Leading and trailing whitespace, commas, etc., are not permitted: digits only, followed by a single newline. ----------------------------------------------------------- Good luck to all the golfers, /-\ndrew Send entries to: mailto:[EMAIL PROTECTED] # teven.pl. Get even golf game test program. use strict; my $have_stderr_redirect = 1; if ($^O eq 'MSWin32') { if (Win32::IsWinNT()) { print "You are running Windows NT/2000\n"; } else { print "You are running Windows, but not Windows NT/2000\n"; $have_stderr_redirect = 0; } } else { print "Congratulations! You are not running Windows.\n"; } 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; } sub PrintGolfScore { my @scr = @_; my $tot = 0; for my $s (@scr) { my $g = GolfScore($s); print "$s: $g\n"; $tot += $g; } print "You shot a round of $tot strokes.\n"; } sub BuildFile { my ($fname, $data) = @_; local (*FF); open(FF, '>'.$fname) or die "error: open '$fname'"; print FF $data; close(FF); } sub CheckOne { my ($scr, $label, $data, $exp) = @_; my $intmp = 'in.tmp'; my $errtmp = 'err.tmp'; BuildFile($intmp, $data); my $cmd = "$^X $scr $intmp"; $cmd .= " 2>$errtmp" if $have_stderr_redirect; print "$label: running: '$cmd'..."; my $out = `$cmd`; my $rc = $? >> 8; print "done.\n"; if ($have_stderr_redirect) { -s $errtmp and die "oops, you wrote to stderr (see $errtmp)\n"; } else { warn "warning: cannot check you did not write to" . " stderr on this platform.\n"; } if ($out ne $exp) { warn "Expected:\n"; print STDERR $exp; warn "Got:\n"; print STDERR $out; die "\nOops, you failed.\n"; } } sub CheckOneGs { my ($scr, $label, $data, $expout, $experr) = @_; my $intmp = 'in.tmp'; my $errtmp = 'err.tmp'; BuildFile($intmp, $data); my $cmd = "$^X $scr $intmp"; $cmd .= " 2>$errtmp" if $have_stderr_redirect; print "$label: running: '$cmd'..."; my $out = `$cmd`; my $rc = $? >> 8; print "done.\n"; if ($have_stderr_redirect) { -s $errtmp or die "oops, you did not write to stderr\n"; local (*FF); local $/ = undef; open(FF, $errtmp) or die "error: open $errtmp: $!"; my $err = <FF>; close(FF); my $num_nl = $err =~ tr/\n//; $num_nl == 1 or die "error: stderr has $num_nl newlines (not 1)" . ", see $errtmp\n"; chop($err); $err =~ /\D/ and die "error: stderr has non-numerics, see $errtmp\n"; if ($err != $experr) { print STDERR "stderr Expected:"; print STDERR $experr; print STDERR " Got:"; print STDERR $err; die "\nOops, you failed.\n"; } } else { warn "warning: cannot check you wrote byte count to" . " stderr on this platform.\n"; } if ($out ne $expout) { warn "stdout Expected:\n"; print STDERR $expout; warn " Got:\n"; print STDERR $out; die "\nOops, you failed.\n"; } } # ----------------------------------------------------- my $words1 = <<'GROK'; a abbreviate abbatestaaaaxuzuzcycyxeexeiiiigogo abbatestaaaaxuzuzcycyxeexeiiiigogo aerate abbatestaaaaxuzuzcycyxeexeiiiigogz abbatestaaaaxuzuzcycyxeexeiiiigogz abbatestaaaaxuzuzcycyxeexeiiigogoz abbatestaaaaxuzuzcycyxeexeiiigogoz abbatestaaaaxuzuzcycyxeexiiiigogoz abbatestaaaaxuzuzcycyxeexiiiigogoz abbatestaaaaxuzuzcycxeexeiiiigogoz abbatestaaaaxuzuzcycxeexeiiiigogoz abbatestaaaaxuzzcycyxeexeiiiigogoz abbatestaaaaxuzzcycyxeexeiiiigogoz abbatestaaaxuzuzcycyxeexeiiiigogoz abbatestaaaxuzuzcycyxeexeiiiigogoz aghast anal antidisestablishmentarianism appeased arrays artificialities autrijus averaged avocados bactrian backhand be bleach buffy camel capitalist cat damian dereference dipsy dissimilarities divisibility doctor dromedary ee ee eugene eighties fanaticism fee feel fungus golf golfer heterogeneousness impossibilities inadmissibility incompatibilities incontrovertible individualistic individualize indivisibility inevitabilities initialization initializing institutionalizing intelligibility interdependence interdependencies invisibility italic italicize iterate japh kangaroo karsten larry meekly merlyn monger obsolete octal odious office piers pony representativeness riding santa spiff undo unjustly unlucky unusable upload usage wretches ww GROK my $words2 = <<'GROK'; aaa jjjaaaeeeiiiooouuuyyy aab aeiouyybbcd aaa jjaaaeeeiiiooouuuyyy aab aeiouyybcd abbreviate aficionado blames booboo booty chipmunk circuit chock crosswords flagellate inkling pipeline zaa zzaaaaei zaa zzaaaaeo zaa zzaaaaeu zaa zzaaaaey zaa zzaaaaio zaa zzaaaaiu zaa zzaaaaiy zaa zzaaaaou zaa zzaaaaoy zaa zzaaaauy zee zzeeeeai zee zzeeeeao zee zzeeeeau zee zzeeeeay zee zzeeeeio zee zzeeeeiu zee zzeeeeiy zee zzeeeeou zee zzeeeeuy zee zzeeeeiy zii zziiiiae zii zziiiiao zii zziiiiau zii zziiiiay zii zziiiieo zii zziiiieu zii zziiiiey zii zziiiiou zii zziiiioy zii zziiiiuy zoo zzooooae zoo zzooooai zoo zzooooao zoo zzooooau zoo zzooooay zoo zzooooeo zoo zzooooeu zoo zzooooey zoo zzooooiu zoo zzoooouy zuu zzuuuuae zuu zzuuuuai zuu zzuuuuao zuu zzuuuuau zuu zzuuuuay zuu zzuuuuei zuu zzuuuueo zuu zzuuuuey zuu zzuuuuio zuu zzuuuuiy zyy zzyyyyae zyy zzyyyyai zyy zzyyyyao zyy zzyyyyau zyy zzyyyyei zyy zzyyyyeo zyy zzyyyyeu zyy zzyyyyio zyy zzyyyyiu zyy zzyyyyou zzz zaechy zzz zaichy zzz zaochy zzz zauchy zzz zeichy zzz zeochy zzz zeuchy zzz ziochy zzz ziuchy zzz zouchy GROK my $words3 = <<'GROK'; aficionado blames booboo GROK # ----------------------------------------------------- my $gs0 = <<'GROK'; hello GROK my $gs0a = $gs0; chop($gs0a); my $gs0exp = 'hello'; my $gs1 = <<'GROK'; aficionado blames booboo GROK my $gs1a = $gs1; chop($gs1a); my $gs1exp = 'aficionadoblamesbooboo'; my $gs2 = <<'GROK'; Buffy is like Catherine the Great GROK my $gs2a = $gs2; chop($gs2a); my $gs2exp = ' Buffy is likeCatherine theGreat'; my $gs3 = <<'GROK'; GROK my $gs3exp = ''; # ----------------------------------------------------- sub CheckEven { my ($scr) = @_; my @tt = ( [ 'words1', $words1, "abbatestaaaaxuzuzcycyxeexeiiiigogo\n". "aghast\n". "avocados\n". "backhand\n". "doctor\n". "ee\n". "fanaticism\n". "feel\n". "incontrovertible\n". "kangaroo\n". "obsolete\n". "wretches\n" ], [ 'words2', $words2, "aficionado\n". "booboo\n". "flagellate\n". "pipeline\n" ], [ 'words3', $words3, "" ], ); for my $r (@tt) { CheckOne($scr, $r->[0], $r->[1], $r->[2]) } } sub CheckGs { my ($scr) = @_; my @tt = ( [ 'gs0', $gs0, $gs0exp, length($gs0exp) ], [ 'gs0a', $gs0a, $gs0exp, length($gs0exp) ], [ 'gs1', $gs1, $gs1exp, length($gs1exp) ], [ 'gs1a', $gs1a, $gs1exp, length($gs1exp) ], [ 'gs2', $gs2, $gs2exp, length($gs2exp) ], [ 'gs2a', $gs2a, $gs2exp, length($gs2exp) ], [ 'gs3', $gs3, $gs3exp, length($gs3exp) ], ); for my $r (@tt) { CheckOneGs($scr, $r->[0], $r->[1], $r->[2], $r->[3]); } } # ----------------------------------------------------- my $even = 'even.pl'; my $gs = 'gs.pl'; select(STDERR);$|=1;select(STDOUT);$|=1; # auto-flush -f $even or die "error: file '$even' not found.\n"; -f $gs or die "error: file '$gs' not found.\n"; PrintGolfScore($even, $gs); CheckEven($even); CheckGs($gs); PrintGolfScore($even, $gs); print "Hooray, you passed.\n";
