Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Challenge: prefix($x, $y) . suffix($x, $z) eq $x

by shmem (Chancellor)
on Apr 22, 2009 at 21:30 UTC ( [id://759417]=note: print w/replies, xml ) Need Help??


in reply to Challenge: prefix($x, $y) . suffix($x, $z) eq $x

Here's my straight forward solution, ungolfed...

timed as

real 0m0.387s user 0m0.381s sys 0m0.003s

update: using Limbic~Region's name list I get

real 0m12.441s user 0m12.219s sys 0m0.015s

and replacing m// with index in sub suffix above

real 0m6.405s user 0m6.273s sys 0m0.007s

on a Pentium M 2.10GHz, perl 5.8.8 - What are your timings? What is "better"? Code readability, brevity, maintainability, performance?

;-)

Replies are listed 'Best First'.
Re^2: Challenge: prefix($x, $y) . suffix($x, $z) eq $x
by Limbic~Region (Chancellor) on Apr 22, 2009 at 22:18 UTC
    shmem,
    What is "better"?

    Bah, I was just baiting folks into contributing. I do see a syntax error in what you posted (last if block is missing closing curly)? After correcting that typo, it takes about 11 wallclock seconds to run the tennis name list. Thanks for your contribution :-)

    Cheers - L~R

      I do see a syntax error

      Thanks, corrected. - I seem to just have learned something about index: use it! Did cut the wallclock time to the half it did... ;-) ... see my update.

        shmem,
        This doesn't seem to scale very well. I started to run it against a 60K word dictionary file and I gave up waiting for it to produce output after a few minutes. Perhaps you could modify it to accept a target word from the command line and only do all matches if one isn't provided?

        Cheers - L~R

Log In?
Username:
Password:

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

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

    No recent polls found