Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Hello

Here is my solution (176 chars if data is joined in a single string in $_). Do you have a test suite?

$_ = join '', @b; s#(.)/(.)$#$1.(10-$1).$2#e;s# ?#a#g; s#XaXaXa$#10a10a10a#;s#Xa(\da\da)$#10a$1#; 1while s#Xa(\d+)a(\d+)#10a$1a$2a$1a$2#|| s#(\d+)a/a(\d+)#"$1a".(10-$1)."a$2a$2"#e; $s+=$_ for/\d+/g; print "$_: $s\n";
Hope it's correct.

Aziz,,,

update:removed an extra $1 at the end of line 2 and added a missing 'a'. Score: 176 from 177

Major Update:

That code was wrong. Here is an update that works for the test cases: (score 131)

update:wrote it in sub form: score 144

print score(join'',qw(5 / 6 3 X X 7 0 4 3 X 4 / 8 1 3 / 6)),"->146\n"; print score(join'',qw(X X X X X X X X X X X X)), "->300\n"; print score(join'',qw(0 / X 0 / X 0 / X 0 / X 0 / X 0 /)),"->200\n"; print score(join'',qw(X 0 / X 0 / X 0 / X 0 / X 0 / X 0)),"->200\n"; sub score={ # 1 2 3 4 5 6 #234567890123456789012345678901234567890123456789012345678901234567890 ($_,$s)=@_;1while s#(.)/(.)#$1.($1<1?'x':10-$1)."\L$2y".$2#e||s#X(\d\d +)#x$1$1#||s#X(..)#"x\L$1z".$1#e||s#(y.|z..)$##||s#x#55#;$s+=$_ for/\d +/g;$s ##### }
CreditTo dragonchild for providing the test cases


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

Title:
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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (8)
    As of 2014-12-21 07:11 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (104 votes), past polls