in reply to TPR(0,1) Golf Tournament Begins!
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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: TPR(0,1) Golf Tournament Begins!
by Amoe (Friar) on Mar 01, 2002 at 17:55 UTC |