I thought I would describe a little bit of background to the
tournament in case anyone is interested.

Unlike Santa's game, where I simply chose some standard utilities,
like head and tail, without any regard to golfing, this time I
wanted to "cook" an interesting golf hole.

To do that, I had to test it to verify that multiple solutions
were indeed possible and with similar scores. I was lucky to
have two helpers in this endeavour: "Ginger Spice" and
"Eat My Shorts" (EMS) (I am using their nicknames in case
they object to being named in a public forum).

After a few days, Ginger and EMS both came up with excellent and
different 51-stroke solutions. At this time, I was in love with:

-ln 1&($.|y|||c|y|a|||y|e|||y|i|||y|o|||y|u|||y|y||)||print 59 bob

I realised, however, there must be a way to harness 'eval'
to get rid of all that beautiful code duplication.
As a proof of concept, I came up with:

-p eval sprintf'$_=""if($.|~y&%s&&c)&1;'x7,Zyoueia=~/./g    56 bob

Now 'join' is 3 strokes less than 'sprintf', but I had a blind spot
and did not think of that. However, I did what I often do when
feeling desperate in a golf game and took the Camel home that night
and went thru every single function in alphabetical order asking
the question: "Can I use this function?". When I got to "glob" I
initially said "No, I am not interested in looking for files on
disk" but then I remembered a post by Perl Monk tilly (something
about a color chart) where he used glob in a most perverse way.
I had never done this myself, however, so I started with a small
program:

@a = glob('|y|{a,e,i,o,u,y,}||c');
for my $x (@a) { print "x=$x\n" }

This produced a list of just the type I wanted!
Now, since glob is the internal function used by the <> operator,
I got a little more adventurous and tried:

@a = <|y|{a,e,i,o,u,y,}||c>;
for my $x (@a) { print "x=$x\n" }

Bingo! The only thing left was to figure out how to convert that
into a string for eval. I could see no better way than the
standard @{[]} notation, finally producing:

-ln 1&eval"$.@{[<|y|{a,e,i,o,u,y,}||c>]}"||print            48 bob

When I showed this to Ginger and EMS they said "That's it, that's
the limit". I said "No, No, No, wait and see, there is this Dutch
guy, Eugene van der Pijll, he will beat it for sure!".
Thanks Eugene, for proving my prediction correct. :)

/-\ndrew

Reply via email to