Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: (Golf) Let's go bowling

by abstracts (Hermit)
on Aug 08, 2001 at 22:20 UTC ( #103147=note: print w/ replies, xml ) Need Help??


in reply to (Golf) Let's go bowling

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


Comment on Re: (Golf) Let's go bowling
Select or Download Code
Re: Re: (Golf) Let's go bowling
by dragonchild (Archbishop) on Aug 08, 2001 at 22:35 UTC
    Your solution returns the following results:
    qw(5 / 6 3 X X 7 0 4 3 X 4 / 8 1 3 / 6) 146 qw(X X X X X X X X X X X X) 300 qw(0 / X 0 / X 0 / X 0 / X 0 / X 0 /) 0 (should be 200) qw(X 0 / X 0 / X 0 / X 0 / X 0 / X 0) 0 (should be 210)
    And, in subroutine form, I count 192. (My counts were off cause my window wasn't 80 characters wide. Fixed now. *blushes*)

    Update:

    qw(0 / X 0 / X 0 / X 0 / X 0 / X 0 /) 0 (should be 200) qw(X 0 / X 0 / X 0 / X 0 / X 0 / X 0) 172 (should be 200)

    ------
    /me wants to be the brightest bulb in the chandelier!

    Vote paco for President!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (16)
As of 2015-07-06 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (77 votes), past polls