Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: PGA Golf, Round 1 - Results

by japhy (Canon)
on Jun 01, 2001 at 02:34 UTC ( [id://84776]=note: print w/replies, xml ) Need Help??


in reply to PGA Golf, Round 1 - Results

I disagree on #3's minimum score, as seen by my comments in my answer:
# 3 -- 23 chars # note: using $ instead of \z is *wrong* # note: using . without /s is *wrong* sub g3 { pop=~/^(.*?)\1+\z/s&&$1 }
For that matter, par is 22:
sub g3 { pop=~/^(.*?)\1+\z/s;$1 }


japhy -- Perl and Regex Hacker

Replies are listed 'Best First'.
Re (tilly) 2: PGA Golf, Round 1 - Results
by tilly (Archbishop) on Jun 01, 2001 at 02:42 UTC
    Agreed. 22 is the best that I have.

    For a bit I mistakenly thought I had a 20 char solution in the form of:

    sub hole{map/^(.*?)\1+\z/s,@_}
    but the rules say that if a single thing is returned, then it will be in scalar context. In scalar context this solution is wrong (as I indicated in an "oops" update).
Re: Re: PGA Golf, Round 1 - Results
by chipmunk (Parson) on Jun 01, 2001 at 05:46 UTC
    Yup, this is another one of those tricky edge cases... which the committee missed completely! We forgot about newlines in the strings.
Re: Re: PGA Golf, Round 1 - Results
by jmcnamara (Monsignor) on Jun 01, 2001 at 13:20 UTC

    I disagree on #3's minimum score, as seen by my comments in my answer:

    I noted this when you first posted it. I tried to account for it by adding 2 chars to the posts that had omitted \z and /s. However, I didn't get it right in all cases.

    Although, the PGA questions were well specified, it is always possible to miss a boundary condition like this. I should have modified the question to either make this requirement explicit or to specify that it wasn't required.

    John.
    --

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-20 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found