Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Just for the record, here's a fairly straightforward one treating the score as a string.  It replaces '/' with the appropriate count and dupes the following char (unless it's an extra ball), replacing X with x to avoid processing the X twice.  Then it dupes the 2 chars following each X (again, except for extras), and tallies.  It passes all of the above tests and comes in at 96 chars:
sub score { $_=pop; # 7 s#(.)/(?=(.).|.?$)#$1.($1?10-$1:'x').lc$2#ge; # 45 s/X(?=(..).)/X$1/g; # 19 y/Xx/9/+eval join'+',/./g # 25 } # ___ # 96
Only one problem, it fails for a strike in the 9th frame and no extra balls in the 10th!  /X\d\d$/ matches either. (Also, there's no agreement on whether the args passed in have to match the orginal @b example.) Patching for those makes it 123 :-( :
sub fullscore { $_=join'',@_; # 13 s/^(X|\d.){10}$/$&0/; # 21 s#(.)/(?=(.).|.?$)#$1.($1?10-$1:'x').lc$2#ge; # 45 s/X(?=(..).)/X$1/g; # 19 y/Xx/9/+eval join'+',/./g # 25 } # ___ # 123


In reply to Re: (Golf) Let's go bowling by petral
in thread (Golf) Let's go bowling by virtualsue

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [LanX]: Yesterday I made B::Concise produce a nested AoH of the optree instead of text
    LanX chacka!!!
    [LanX]: whats the correct way to make a perlbug report for perldoc?
    [erix]: chacka
    [LanX]: with a diff? which perldoc version should I take from where?

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (12)
    As of 2017-04-24 15:15 GMT
    Find Nodes?
      Voting Booth?
      I'm a fool:

      Results (442 votes). Check out past polls.