eiverson@nmsu.edu (Eric Iverson) (04/10/90)
Here's a little puzzler for you. Write a program that handles the following input: gen([a,b,c,d,e,f],[b,c],[d,e],[b,c,d,e]). gen([a,b,c,d,e],[a,b],[c,d],[a,b,c,d]). gen([a,b,c,d,e],[b,c],[d,e],[b,c,d,e]). gen([a,b,c,d],[a,b],[c,d],[a,b,c,d]). gen([b,c,d,e],[a,b,c],[d,e],[a,b,c,d,e]). gen([a,b,c,d],[a,b],[c,d,e],[a,b,c,d,e]). gen([b,c,d,e],[a,b,c],[d,e,f],[a,b,c,d,e,f]). Essentially, given gen(A,B,C,D), make sure that there is a sublist of A such that the first part can be the tail of B, and the second part can be the head of C. At the same time, append B and C to form D. Can this be done in one traversal of the strings? -- ------------------------------------------------------------------------ Another Gruntpig production, in association with the Rat Lab Steamworks. Eric Iverson, president. Eric IVerson, emperor. ERiC IVerSoN, DeMIgOd!!! eiverson@nmsu.edu "I want to kill everyone here with a cute Computing Research Lab colorful Hydrogen Bomb!!" New Mexico State University -Zippy the Pinhead