Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Re: Re: (Golf) Let's go bowling

by dragonchild (Archbishop)
on Aug 11, 2001 at 00:54 UTC ( #104047=note: print w/replies, xml ) Need Help??

in reply to Re: Re: (Golf) Let's go bowling
in thread (Golf) Let's go bowling

Rewriting your code in Golf-ese, just to give you an example, could yield (without really taking into account all the shortcuts) in 166 characters ...
map{s/X/10/;s#/#10-$p#e;$p=$_}@c=@_;$t=$f=$h=0;while(@_){$s=shift@c;$_ +=shift;/[X\/]/&&($t+=$s+$c[0]+(/X/?$c[1]:0),$h=0,++$f>9?last:next);$f +++,$h=0 if$h;$t+=$s;$h++}$t
Golf code isn't meant to be pretty or even readable. It's meant to be compact. :)

/me wants to be the brightest bulb in the chandelier!

Vote paco for President!

Replies are listed 'Best First'.
Re: Re: Re: Re: (Golf) Let's go bowling
by dga (Hermit) on Aug 15, 2001 at 00:32 UTC

    Ok last draft, including dragonchild's compressions and optimizations and correcting the case 6 problem which actually saves 3 more bytes.

    map{s/X/10/;s#/#10-$p#e;$p=$_}@c=@_;$t=$f=$h=0;while(@_){$s=shift@c;$_ +=shift;/[X\/]/&&($t+=$s+$c[0]+(/X/?$c[1]:0),$h=0,++$f>9?last:next);$h +=$h?($f++,0):1;$t+=$s}$t

    163 bytes which is basically 1/2 of the previous length.

    Thanks again dragonchild.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://104047]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2017-05-26 17:51 GMT
Find Nodes?
    Voting Booth?