[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] The Perl Golf Apocalypse Experience



Hi All,

At the Perl Conference 4.0 I was on a Perl Golf Apocalypse team (Team
Bridge) along with two co-workers. I thought I'd write up some
impressions for anyone interested.

Reading this list and seeing the distinguished panel in charge of the
contest made me very reluctant to be on a team when a co-worker
suggested the idea. But I was raised to always face a challenge. I was
also brought up believing that public humiliation and derision build
character, of which you can never have enough. (This explains why I
continue to post to this list. :-}) If those weren't good enough
reasons I finally decided to join with the hope that I would win a
door prize.

The contest was made up of two rounds. The first round was 9 holes
played by 10 teams. The top 5 teams would then continue to another
round to decide the winners. Each hole had a time-limit of 3-6
minutes. Each hole was stored in a separate directory. You cd'ed into
the directory that contained a file with the problem description and
program framework. There was also an "expected results" file to help
you determine if you had a correct answer. You edited the framework,
tested, then copied to another filename to submit your answer. Most of
the problems were not one-liners, but functions in which the golf shot
was the body of the function.

We found the time limits much too short. It took us a minute or so to
understand the problem and formulate an approach. At that point you
had precious little time to code and debug the answer. Let alone try
to make it an elegant and concise golf shot. I think most teams had
trouble completing any of the problems in the time-limit. We only got
one or two of the first 8 answered at all.

The contest was not completed. It was cancelled midway. Due to
technical difficulties I presume. The organizers were having a lot of
trouble with the remote-control system they had developed to ensure
fairness and quick analysis of results. (I'll let Uri, Ron or Nathan
expound if they wish.) Even so, the contest resulted in a lot of fun
for me and my teammates. The evening before the contest at dinner we
were discussing the contest and golf shots I had seen on this list. We
came up with a few problems to solve. Some are dumb or trivial but
being new to Perl golf I think it's cool how easily you can do some
things. Here are our solutions. I would love to see the FWP list's
improvements.

 + Implement cat(1):

    perl -pe\; <file>+

 + Implement yes(1):

    perl -le'print"@ARGV"||"y"while 1'

 + Strip off leading whitespace from each line of a file

    perl -i -pes/^\\s+// <file>
 
 + Copy a file

   perl -e'open B,">".pop;print B<>' <source-file> <target-file>

 + "Backup" files in a directory tree to *.bak

    perl -e'sub x{($a)=@_;(-f)?(open(A,$_),open(B,">$_.bak"),print B<A>):x($_)for<$a/*>}x(shift)' <directory>

Solving these example problems was a lot of fun for my teammates and
me. We learned more Perl. We probably annoyed the guy next to us in
the terminal room. I deem the contest a success as a whole. Thanks,
gentlemen! 

BTW, Uri/Ron/Nathan, can you post the holes that were played during
the contest? I would really like to try my hand at them in a more
relaxed setting.

Hope you have a very nice day, :-)
Tim Ayers (tayers@bridge.com)

P.S. After the contest was cancelled, the organizers decided to pull
numbers out of a hat to divy up the prizes. My team each won the
promise of a cube refrigerator and $40 to stock it with goodies, plus
an Addison-Wesley book. :-)

P.P.S. I regret not getting the chance to introduce myself to Uri, Ron
or Nat in all the commotion. But at least I have faces to go with names.


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe