En op 11 juni 2002 sprak Michael W Thelen:
On Mon, Jun 10, 2002 at 01:27:06PM -0400, Prakash Kailasa wrote:
>> I have until the end stuck myself like a glue to the
>> two (actually four) ungly variables to get and accumulate counts. And
>> to top it off, I had to waste a whopping 8 chars, for initializing two
>> of those variables.
>>
>> $V=$T=0;
>> map{$V+=$v=y/aeiouy//,$T+=$t=s/\w/$&/g;sprintf"%-*s",y///c,"$v/$t"}
> I had those dang variables floating around my program the
> whole time too! :)
Me too. :-(
Finding this simplifying idea would have saved me at least 16
strokes (191->175), it being a trivial transformation from:
#!perl -ap056
$s=$t=0;@n=map{$t+=($s+=@q=/\w/g,$_.=$"x(3-tr)))c),$z=pack
A.y)))c,lc=~y)aeiouy)).v47.@q);$z}@F;s@(.{57})..[^.].+@$1...@,$_=@F.": $_
$t/$s: @n[0..-1+split/[. ]+/]
",s, +$,,mg if$_="@F"
to:
#!perl -ap056
sub Z{lc=~y)aeiouy)).v47.s/\w/$&/g}$X=Z;@n=map{$_.=$"x(3-tr)))c);pack
A.y)))c,Z}@F;s@(.{57})..[^.].+@$1...@,$_=@F.": $_
$X: @n[0..-1+split/[. ]+/]
",s, +$,,mg if$_="@F"
Gee, I would have beaten Keith and even given the great
Stephen Turner the dude who wrote Analog quite a fright.
Am I upset? Not really. Golf is full of "if onlys".
To me, this is part of the charm of the game and it is what
allows beginners to beat hard-boiled veterans; visualizing a
simpler solution often saves you more strokes than ten tons
of Golf technique. (Besides, it would have deprived me of
the joy of my little battle with `/anick, Jay and Sec).
To illustrate, consider Martin Carlsen's 175 (BTW congratulations
Martin!), which used:
1) y/aeiouyAEIOUY//
2) y/a-zA-Z0-9//
3) -np (sic)
Changing to:
1) lc=~y/aeiouy//
2) s/\w/$&/g
3) -p
is easy for a hard-boiled one, but saves only 7 strokes,
compared to the 16 stroke saving described above.
/-\ndrew