I need help programing this promblem,
October 2, 2008 at 7:20 AM
The Zipper
Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. the first two strings can be mixed arbitrarily, but the characters from each must stay in their original order in the third string.
For example, consider forming "tcraete" from "cat" and "tree":
String A: c a t String B: t r e e String C: t c r a e t e
As you can see, we can form string C by alternately selecting characters from strings A and B, starting with string B. As a second example, consider forming " catrtee" from "cat" and "tree";
String A: c a t String B: t r e e String C: t c r a e t e
Finally, notice that it is impossible to form "cttaree" from "cat" and "tree".
INPUT There will be multiple cases to consider. For each case the input consists of three lines, each containing a string, with the string possibly preceded and followed by one or more whitespace characters (blanks and tabs). Each string contains only upper and lower case letters. The length of the third string is always the sum of the lengths of the first two strings. The first two strings will have lengths between 1 and 200 characters, inclusive. The case is followed by a single line that contains a period in the first column.
Output For each case display a line containing the case number (starting with 1 and increasing sequentially), and the word "yes" or "no" to indicate whether the first two strings can be "zippered" to produce the third string. The output format is illustrated in the sample shown below.
Sample Input Output for the sample input
cat Case 1: yes tree Case 2: yes tcraete Case 3: no cat tree catrtee cat tree cttaree