<?xml version="1.0" encoding="windows-1252"?>
<node id="77415" title="Re: (Golf) Fragment Reassembly" created="2001-05-02 17:01:23" updated="2005-07-29 21:37:58">
<type id="11">
note</type>
<author id="51812">
satchboost</author>
<data>
<field name="doctext">
This is a really cool problem! ++, [MeowChow].&lt;p&gt;
&lt;code&gt;
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&lt;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
}
&lt;/code&gt;
&lt;p&gt;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.</field>
<field name="root_node">
77183</field>
<field name="parent_node">
77183</field>
</data>
</node>
