in reply to Re: (Golf) Let's go bowling
in thread (Golf) Let's go bowling
Per my update above this one is less than 1/3 the other and still works if you use use strict; (and warnings)
{ my(@g)=@_; my(@c)=@g; my($t, $s, $m, $p, $f, $h); foreach (@c) { s/[Xx]/10/; s/\//10-$p/e; $p=$_; } while(@g) { $s=shift(@c); $_=shift(@g); /X/ && ($t += $s + $c[0] + $c[1], $f++, $h=0, $f>9?last:next) +; /\// && ( $t += $s + $c[0], $f++, $h=0, $f>9?last:next); $h=$h?($f++,0):1 $t+=$s; $h++; } $t; }
Dropping the my lines will of course stop strict from letting it run and will erase the callers copy of all the arguments to the function. But it is more than 10% smaller...
Update: Failed case 6 of virtualsue's test suite now works correctly.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: (Golf) Let's go bowling
by dragonchild (Archbishop) on Aug 11, 2001 at 00:54 UTC | |
by dga (Hermit) on Aug 15, 2001 at 00:32 UTC |
In Section
Meditations