On Tue, Jan 29, 2008 at 12:11:56PM -0500, Tolkin, Steve wrote: > I am looking for a perl program that will solve the following problem. > Suppose I have 2 or more lists that are (conceptually) sublists of the > same underlying list. > I want to reconstruct the underlying list. In other words the order of > the elements agrees in all the lists, but there is no sort condition. > > Example: > List 1: dog, cat, mouse > List 2: dog, shark, mouse, elephant > > There are 2 possible outputs, and I do not care which one I get.
Sounds like a problem begging for tsort. 'man tsort' or 'info coreutils tsort'. Should be on most unixoid systems. You'd need to pre-process your data into pairs of strings and feed that to tsort, which will produce one of the possible totally ordered outputs. $ tsort <<EOS dog cat cat mouse dog shark shark mouse mouse elephant EOS -Gyepi _______________________________________________ Boston-pm mailing list [email protected] http://mail.pm.org/mailman/listinfo/boston-pm

