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

Re: Golf (Inspired): Repeated Phrases

by chipmunk (Parson)
on May 10, 2001 at 21:01 UTC ( #79476=note: print w/ replies, xml ) Need Help??


in reply to Golf (Inspired): Repeated Phrases

Okay.... I was quite close with my original solution, but failed to fully test it. MeowChow pointed out the error in my approach; {$n,$m} will only match once, whereas I need it to match the whole range from $n to $m.

So, I just needed to add another loop, and voila:

sub repeated { ($_,$t,$n,$m,@p)=@_; for$i($n..$m){$t=~$1&&push@p,$&while/\b(?=((\w+\b ?){$i}))/g}@p }
So that's 83 characters long, with help from MeowChow's solution.


Comment on Re: Golf (Inspired): Repeated Phrases
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2015-07-07 03:13 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 (86 votes), past polls