develooper Front page | | Postings from September 2002

The Mr Magoo Awards (tpr05a)

Thread Next
September 10, 2002 05:31
The Mr Magoo Awards (tpr05a)
Message ID:
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:

use strict;
my $test_prog    = '';
my $hole_prog    = '';
my $too_fat_prog = '';
my $too_fat      = "";
{  open(my $fh, $too_fat_prog) or die "open '$too_fat_prog': $!";
   local $/ = undef; $too_fat = <$fh>;
$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;  # (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 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 before Sunday. :-(((((

Here are some other Mr Magoos:
  Adam Antonik i=51 '\' i=120 '*' i=51 '*'
Just by running, 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


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About