in reply to Ponder This: the worm-eaten page

perl -le '$_ = "@{[1 .. 9999]}"; s/[ 0]+/+/g; print eval'

Replies are listed 'Best First'.
Re^2: Ponder This: the worm-eaten page
by Jasper (Chaplain) on Dec 17, 2004 at 13:07 UTC
    bit shorter
    perl -le 'print eval join'+',map{split/0+/}1..9999'
      But I suppose this is cheating:
      perl -le 'map$\+=$_,map/[^0]+/g,1..9999;print'
Re^2: Ponder This: the worm-eaten page
by pijll (Beadle) on Dec 17, 2004 at 16:50 UTC
    perl -le '$_=join 0,1..9999;y/0/+/s;print eval'

      Gasp, what a beautiful orange! Could this really be brilliant Dutch golfer (-ugene in disguise? If so, he might be irritated if someone shaved a single stroke from his lovely solution. ;-)

      # One stroke improvement on (-ugene. ^.^ perl -le '$_=join 0,1..9x4;y/0/+/s;print eval' # And a couple of longer ones for fun. perl -le 'print eval join"+",map/[^0]+/g,1..9x4' perl -le 's}}join"+",map/[^0]+/g,1..9x4}ee;print' perl -le 's;;$%x9998;e;s;;++$%;eg;y;0;+;s;print eval'
        Everyone seems to optimize the algorithm because they understand the deep nature of the problem. After studying the problem for a very long time, here is my highly optimized version: perl -e 'print 37359000, "\n"'

        $will->code for @food or $$;

Re^2: Ponder This: the worm-eaten page
by gaal (Parson) on Dec 17, 2004 at 11:13 UTC
    Nice++ :)