Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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

by tilly (Archbishop)
on Aug 09, 2001 at 00:36 UTC ( #103211=note: print w/ replies, xml ) Need Help??


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

D'oh. That brings my idea of working in reverse up to 133.

sub hole { $i=$s=0;$s-=$_[-1]if"@_[-2,-1]"=~m!/|X!;map{$s+=$_[$i-1],$_=/X/?($s+=$ +_[$i-2],10):10-$_[$i+1]if/\D/;$s+=$_;$i++}@_=(0,0,reverse@_);$s }


Comment on Re (tilly) 3: (Golf) Let's go bowling
Download Code
Re: Re (tilly) 3: (Golf) Let's go bowling
by tachyon (Chancellor) on Aug 09, 2001 at 01:11 UTC

    Short though this is it fails the test suite

    print score(qw(5 / 6 3 X X 7 0 4 3 X 4 / 8 1 3 / 6)),"--> 146\n"; print score(qw(X X X X X X X X X X X X)), "--> 300\n"; print score(qw(0 / X 0 / X 0 / X 0 / X 0 / X 0 /)),"--> 200\n"; print score(qw(X 0 / X 0 / X 0 / X 0 / X 0 / X 0)),"--> 200\n"; sub score { $i=$s=0;$s-=$_[-1]if"@_[-2,-1]"=~m!/|X!;map{$s+=$_[$i-1],$_=/X/?($s+=$ +_[$i-2],10):10-$_[$i+1]if/\D/;$s+=$_;$i++}@_=(0,0,reverse@_);$s } __END__ 146--> 146 330--> 300 210--> 200 210--> 200

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Grrr. All of the way up to 175:
      sub score { $i=$s=0;map{$b=!(++$i<5&&$_[4]eq X||4>$i&&$_[3]eq'/');$s+=$b*$_[$i-2], +$_=/X/?($s+=$b*$_[$i-3],10):10-$_[$i]if/\D/;$s+=$_ if$b}@_=(0,0,rever +se@_);$s }
      Note that this does not pass the final test in your suite, but the score given in the final test cannot come from a real bowling game. Remove the trailing 0 that I am sensitive to and I pass.

      Ah well. Yet another cute idea killed by horrible boundary conditions.

Re: Re (tilly) 3: (Golf) Let's go bowling
by Brovnik (Hermit) on Aug 09, 2001 at 03:07 UTC
    This appears to fail on runs with a spare or strike in the bonus balls, e.g.
    qw(1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 X X 0) -> 75 should be 65 qw(9 0 9 0 9 0 9 0 9 0 9 0 9 0 9 0 9 0 9 / X) -> 111 should be 101 qw(X X X X X X X X X X X X) -> 330 should be 300 qw(0 / X 0 / X 0 / X 0 / X 0 / X 0 /) -> 210 should be 200
    from my test suite.
    --
    Brovnik

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://103211]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2014-08-20 08:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (107 votes), past polls