The Mr Magoo Awards (tpr05a)

[email protected]
Newsgroups perl.golf
Message-ID <[email protected]>
I finally got around to writing a little program to prevent
you stubbing your putter into the ground behind the ball
when attempting to smoothly stroke a one inch putt into
the hole. Here it is:

# mrmagoo.pl
use strict;
my $test_prog    = 't8.pl';
my $hole_prog    = 'rpn.pl';
my $too_fat_prog = 'toofat.pl';
my $too_fat      = "";
{  open(my $fh, $too_fat_prog) or die "open '$too_fat_prog': $!";
   local $/ = undef; $too_fat = <$fh>;
}
chomp($too_fat);
$too_fat =~ /^#!perl( -.+)?\n/ or die "start script with #!perl\n";
my $sidx = 7;   # "#!perl " or "#!perl\n"
my $eidx = length($too_fat) - 1;
for my $i ($sidx .. $eidx) {
   # next if $i == 72;  # eugene.pl (hack if program hangs)
   my $lose_some_weight = $too_fat;
   $lose_some_weight =~ s/\A(.{$i})(.)/$1/s;
   my $ch = $2;
   print "i=$i '$ch' prog='$lose_some_weight'\n";
   {  open(my $fh, '>'.$hole_prog) or die "open '$hole_prog': $!";
      print $fh $lose_some_weight;
   }
   my $s = `perl $test_prog 2>&1`;
   $s =~ "Congratulations" and warn "*** HIP HIP HOORAY!! i=$i '$ch'\n";
}

Surely, after a week of staring at your solution, such
a primitive program could not be of any use. Surely,
your solution would not contain an unnecessary character
which could simply be deleted? To put this to the proof,
I ran mrmagoo.pl on a number of the faster entries in
tpr05a, starting naturally with my own, which produced
to my horror:
  *** HIP HIP HOORAY!! i=41 '^'
Oh deary me, I could have beaten Keith and Jas if only
I had written mrmagoo.pl before Sunday. :-(((((

Here are some other Mr Magoos:
  Adam Antonik i=51 '\' i=120 '*' i=51 '*'
Just by running mrmagoo.pl, I was able to shorten Adam's
solution from 120 to 117 without understanding it at all:
#!perl -lp
use overload'""',sub{${$_[0]}},nomethod,a;sub a{$_=pop;
bless/g/?\"-$_[0]":\"@_$_"}s/-/- /g+s/\d+/a("$&")/g;_=eval

In addition to the Speedy Gonzalez award, perhaps Ala also
deserves the Mr Magoo award, for his entry had three hits:
  Ala Qumsieh: i=175 '*' i=177 '/' i=178 '+'

Two more I noticed were:
  Jasvir Nagra: *** HIP HIP HOORAY!! i=81 '$'
  Qingninh Huo: *** HIP HIP HOORAY!! i=34 '+'

I wonder if any of the aliens have more sophisticated
versions of mrmagoo.pl?

/-\ndrew
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.