[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Fun With Golf



On Thu, Oct 19, 2000 at 12:16:59AM +0300, Ilmari Karonen wrote:
> On Wed, 18 Oct 2000 yanick1@sympatico.ca wrote:
> > perlgolf hole - Digital Root
> > Write a subroutine to compute the digital root of any whole number argument.
> > 
> > 	sub hole {pop=~/./;$'?hole($&+$'):$&}
> 
> So what's wrong with the arithmetic approach?
> 
>   sub hole {$_&&(abs($_)-1)%9+1}
> 
> If the numbers were known to be positive, ($_-1)%9+1 would suffice.

	Ooh, I forgot about that one... I'm humbled, awed and beaten. 
Ooooh, wow and dammit. :)

Joy,
Yanick

-- 
($\,$x,$l)=("\n",' substr($s,$l,$i)',-length($s='8910111632'
.'97110'.(1x5).'6104101114328010111410832104979910710111446'
));{$i++until$1+grep$_>123,eval$x,$i;$i--;eval"$x=chr$x";
print$s;($l+=$i)<0&&redo;}

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe