Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2015-11-29 10:24 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (750 votes), past polls