Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by tachyon (Chancellor)
on Aug 09, 2001 at 00:11 UTC ( [id://103204]=note: print w/replies, xml ) Need Help??


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

Here is the frame by frame score (ignore the toggle :-)

Frame tog ball score total 0 5 1 1 / 16 16 0 6 2 1 3 9 25 3 1 X 27 52 4 1 X 17 69 0 7 5 1 0 7 76 0 4 6 1 3 7 83 7 1 X 20 103 0 4 8 1 / 18 121 0 8 9 1 1 9 130 0 3 10 1 / 16 146 6

cheers

tachyon

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

Replies are listed 'Best First'.
Re (tilly) 3: (Golf) Let's go bowling
by tilly (Archbishop) on Aug 09, 2001 at 00:36 UTC
    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 }

      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.

      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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://103204]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-18 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found