Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

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

    No recent polls found