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 | [reply] |
|
| [reply] |
|
| [reply] [d/l] |
|
|
|
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.
| [reply] |
|
| [reply] |
|
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
| [reply] |
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. | [reply] |
|
We are having some minor difficulties with the scoring algorithm. Should be fixed shortly.
| [reply] |
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 | [reply] [d/l] |
|
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 | [reply] [d/l] [select] |
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. | [reply] |
|
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.
| [reply] |
The Domain Of Golf Experts - Re: TPR(0,1) Golf Tournament Begins!
by metadoktor (Hermit) on Mar 02, 2002 at 13:03 UTC
|
| [reply] |
|
| [reply] |