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

Perl Golf as a sport

Thread Next
From:
Andrew.Savige
Date:
March 9, 2002 21:05
Subject:
Perl Golf as a sport
Message ID:
694BB7191495D51183A9005004C0B05452DC95@ir-exchange-srv.ir.com.au
It is clear from recent games that Perl Golf is a sport,
not so different from chess, or real golf for that matter.
There is strategy there, and tactics too -- with tactics
predominant, in my opinion.

I would like to illustrate this sporting aspect of the game
with some examples from recent play, featuring some of our
leading Perl golfers.

1) Don't get too emotional. Aim for a mental state of relaxed
   indifference.

I first learnt the importance of this from playing bridge, where
it is fatal to become angry with partner for making an idiotic bid
or to get too excited if you just brought home a grand slam.
Similarly, in real golf, you must remain equally calm inside,
whether you just shot eagle or double bogey.

Rick Klement bolted to the lead in the Get Even game with
this little gem:

-p  $_ x=1&~$.&~s/$&/$&/gwhile'aeiouy.'=~/./g   [44]

At this stage, he enjoyed a heady eight stroke advantage over
his nearest pursuer, Eugene van der Pijll. Now, the s/$&/$&/g
is elegant and amusing in the extreme. As Rick said:

'When I found that s/$&/$&/g, I had the "giggles" for a day'

Perhaps Rick became so emotionally attached to this construct
that he subconsciously did not want to improve it.

2) When it becomes plain that you are riding a dead horse, the
   best strategy is usually to dismount as quickly as possible.

From the same game, Eugene was 8 strokes adrift with the pretty:

-p $_ x=1&~eval$..join'__|y _y',_,a,e,i,o,u,Y,'
__c'

Yet he was able to fall out of love with it:

"I abandoned this approach when I saw that Rick Klement was at 69,
a full 8 strokes under my score."

After emotionally detaching himself, he came up with:

-p $_ x=1&~s/$&/$&/g&~$.while aeiouy=~/.?/g

which he quickly improved to a winning:

-p $_ x=1&~$.&split$&while aeiouy=~/.?/g

Rick is a brilliant golfer and I feel sure he would have found the
same "ugly" improvement from s/$&/$&/g to split$& had he not been
suffering from the giggles.

3) Be pragmatic. Don't get too carried away with fanciful solutions.

This is a common failing among chess players; they spend an hour
or more analysing a fanciful line, only to reject it and find
themselves in time trouble later in the game.

Perhaps, Eugene and Stephen Turner fell into this trap in the
secret number game, where they both pursued deliciously complex
variations involving the (${}) construct in preference to simpler
more pragmatic solutions involving s///eg.

Another example of this is Ton in the Get Even game, where he
spent so much time analysing the interesting:

-ln ($a=aeiouy)=~s!!--&~y-!g;eval"\$|$a--c&&print"

that he had little time left to find Eugene's winning solution.

Of course, I may have misread the examples above and am interested
in hearing from the players involved re their mental state during
the plays in question.

Most of the top Perl golfers have such good technique that if you
throw them an idea, they can quickly refine it into a solution.
But how do you find the ideas? I welcome any practical advice on
this, especially from Ton, who seems most prolific in this area.
For example, how do you dream up things like s//pop/e?
Also, the idea of using s///eg inside s///eg never occurred to me;
if it had, I might have been in with a chance.

/-\ndrew


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