#ACSL1819S2. ACSL1819S2

ACSL1819S2

PROBLEM: A useful computer utility is to report the differences between two files. In this program, you will compare two strings to find common strings. For this program, a string consists of "words; words are letters which are separated by a single space.

The following algorithm will be used first: Consider each word in turn from left to right in the first string. If that word appears as a word or part of a word in the second string, add the word to the resulting common string and delete the entire first occurrence of the word where it was found in the second string. For example, if "add" is in the first string and "addition" is in the second string, the "add is deleted from "addition" leaving "ition" in the second string. Words are separated by one space in the common string. Upper and lower case letters are considered different letters.

Then use this second algorithm: Consider each character in turn in the first resulting common string. If it appears in the second resulting common string, add it to a new resulting common string and delete all characters in the second resulting common string up to and including that character. Ignore blanks.

Consider the following 2 strings:

A. The quick brown fox did jump over a log

B. The brown rabbit quickly did outjump the fox

Diffing A to B gives a result of "The quick brown fox did jump a"

Diffing B to A give a results of "The brown did fox"

Using the second algorithm produces: Theiox

INPUT: 5 sets of data, where each set consists of2 strings, each on a separate line. Each string will be at most 100 characters. Blank lines are shown for readability ONLY!

OUTPUT: For each pair of strings (call them A and B), find the common string by diffing A to B and diffing B to A using the first algorithm. Then using the resulting 2 common strings apply the second algorithm. Print the resulting common string. If it is empty, print "NONE"

SAMPLE INPUT

The quick brown fox did jump over a log
The brown rabbit quickly did outjump the fox

How many pickled peppers did Peter Piper pick
Peter Piper picked a peck of pickled peppers

The AllStar Contest is in Wayne Hills NJ
Hills are where there are contestants from NJ

Fuzzy Wuzzy was a bear Fuzzy Wuzzy had no hair
Fuzzy Wuzzy was not fuzzy was he

Super cali frigi listic expi alli docious
frigid call superman allies expired list

SAMPLE OUTPUT

Theiox
pickledpeppers
HillsNJ
FuzzyWuzzywas
i