Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: (Golf) Fragment Reassembly

by satchboost (Scribe)
on May 02, 2001 at 21:01 UTC ( #77415=note: print w/ replies, xml ) Need Help??


in reply to (Golf) Fragment Reassembly

This is a really cool problem! ++, MeowChow.

sub assemble { $x='';sub a{($p,$q)=@_;return$q if!$p;$l=length$p;for(0..$l){$y= substr($p,0,$_).$q;return$y if substr($y,0,$l)eq$p}}sub b{my$s;$s=a( $s,$_)for@_;$x=$s if!$x||length$s<length$x;} sub c{my($a,$b)=@_;if(@$b){for(0..$#$b){my@c=@$b; c([@$a,splice@c,$_,1],[@c])}}else{b @$a}}c([],[@_]);$x }

279 by my count. I know I could cut this down further in the recursion, but I'm damned if I can see it right now.


Comment on Re: (Golf) Fragment Reassembly
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2014-04-18 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (462 votes), past polls