Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

TPR(0,1) Golf Tournament Begins!

by redsquirrel (Hermit)
on Mar 01, 2002 at 15:55 UTC ( [id://148591]=perlmeditation: print w/replies, xml ) Need Help??

The Perl Review is hosting the TPR(0,1) Golf Challenge. The contest runs from now to March 8 00:00 GMT.

We will not be accepting any solutions directly through email this month as we try out our new PGAS (Perl Golf Administration System). TPR(0,1) golfers will submit their solutions via the web. This allows PGAS to store your information in a database, which makes it much easier on the referees to administer. Please let me know if (OK, when) you encounter bugs or if you have any feedback or suggestions.

Rules and info can be found at:
http://perlgolf.sourceforge.net/TPR01/

Enjoy,
--Dave

Replies are listed 'Best First'.
Re: TPR(0,1) Golf Tournament Begins!
by redsquirrel (Hermit) on Mar 01, 2002 at 19:27 UTC
    PLEASE DO NOT POST TPR(0,1) SOLUTIONS HERE ON PERL MONKS!!

    During Perl Golf tournaments all solutions should be submitted to the referees and not posted publicly. This makes for a much more competitive tournament and allows there to be such things as leaderboards and individual achievement. It also forces beginners to RTFM and learn how to play golf without using code they don't understand.

    Thanks,
    --Dave

      While I understand the desire to not have public discussion during a competition, for me that ruins most of the fun. What I find most enjoyable is seeing how other people run with my ideas and how I can run with theirs. Public posting and discussion facilitates that.

      However I can see why people who consider "winning" important wouldn't agree with me, so I will bow out of this.

        Golf is an individual sport: players hit the balls themselves, and others can't help the player with getting the ball into the hole.

        But... others CAN watch the player, imitate him, and learn from his moves. And I think we should encourage that.

        I also like to see other people use my ideas, and I don't care much for winning at all. Although I'm not a beginner in Perl, Perl Golf is quite new to me, and I have much to learn.

        I would like to post my entry over here :(
        (My current score is 72 strokes)

        Lbh ebgngrq guvf grkg naq abj lbh pna ernq vg. Fb jung? :) -- Whreq

      Are you going to post the top entries here? Please do so, cause I know my golfing skills have improved ten-fold, just by reading the golfs here by japhy, masem, and ovid, among others.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

        The top entries will be deconstruced in a future TPR issue. All entries will be posted when the tournament is over. I will repost this URL here when that happens.

        Yes, reading through Golf Tournament post-mortems is an extremely effective way to improve your golf game.

      Amoe hurriedly puts on asbestos trousers

      Very sorry. That wasn't a serious thing - hell, I'm nowhere near skilled enough to enter it, that's why I didn't submit it. I just thought it might inspire people to get started. Obviously that was wrong. You can reap my nodes now :)



      --
      my one true love
Re: TPR(0,1) Golf Tournament Begins!
by dragonchild (Archbishop) on Mar 01, 2002 at 19:38 UTC
    It's interesting - tpr01 had me at 69 strokes, but PGAS recorded me at 70 ... ??

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      We are having some minor difficulties with the scoring algorithm. Should be fixed shortly.
Re: TPR(0,1) Golf Tournament Begins!
by Amoe (Friar) on Mar 01, 2002 at 17:46 UTC

    Here's a basic, non-golf implementation as a starter.

    #!/usr/bin/perl -w use strict; my $secret = shift; until (length $secret == 1) { print "$secret\n"; $secret = tpr($secret); } print "$secret\n"; sub tpr { my @digits = split //, shift; my $not_so_secret; while (my @pair = splice @digits, 0, 2) { unshift @digits, $pair[1] unless !@digits; my $res = $pair[0] + $pair[1]; until ($res <= 9) { my $cpy = $res; $res = 0; for (split //, $cpy) { $res += $_; } } $not_so_secret .= $res; } return $not_so_secret; }


    --
    my one true love

      Heh...the experts are already way ahead of me, but as a beginner, I thought I'd try anyway. Apparently, 229 chars with very simple whitespace removal:

      my$s=shift;until(length$s<2){print"$s\n";$s=tpr($s)}print"$s\n";sub tpr{my@d=split//,shift;my $s;while(my@p=splice@d,0,2){unshift@d,$p[1] unless!@d;my$r=$p[0]+$p[1];until($r<=9){my$c=$r;$r=0;for(split//,$c){ $r+=$_}}$s.=$r}$s}

      Update: abuse of map brings it to 227. Is whitespace counted? I'd hate to make it a horrible one-line thing...

      my$s=shift;until(length$s<2){print"$s\n";$s=tpr($s)}print"$s\n";sub tpr{my@d=split//,shift;my $s;while(my@p=splice@d,0,2){unshift@d,$p[1] unless!@d;my$r=$p[0]+$p[1];until($r<10){my$c=$r;$r=0;map{$r+=$_}split //,$c}$s.=$r}$s}


      --
      my one true love
Re: TPR(0,1) Golf Tournament Begins!
by dragonchild (Archbishop) on Mar 04, 2002 at 19:52 UTC
    Just a note - I discovered (by accident) that the referees do not test "00" to make sure it goes "0", then blank. You guys accepted a solution of mine that goes "00" then done. (I don't have independent email, otherwise I'd've emailed you.)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      From the rules (emphasis mine):
      You may assume that there will be only one arg on the command line, which will be a properly formatted number (matching the pattern /^[1-9]\d*\z/ or 0). Numbers will range from 0 to 2**32 - 1 (4294967295) inclusive. There will be no leading 0's.
The Domain Of Golf Experts - Re: TPR(0,1) Golf Tournament Begins!
by metadoktor (Hermit) on Mar 02, 2002 at 13:03 UTC
    I wonder if anyone other than Perl Golf experts should even bother attempting to enter the tournament, after all, who can compete with 33 char Golf rounds??? :)

    I was actually surprised to see so many entries on the last round.

    metadoktor

    "The doktor is in."

      ...surprised to see so many entries on the last round

      Golf tournaments are suprisingly addictive whether or not you're an elite golfer. Everytime I play (or referee) I learn a bit more about Perl.

      --Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://148591]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-26 01:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found