Programming Challenge Description:
You will be given a sequence of passages, and must filter out any passage whose text (sequence of whitespace-delimited words) is wholly contained as a sub-passage of one or more of the other passages.
When comparing for containment, certain rules must be followed:
-The case of alphabetic characters should be ignored
-Leading and trailing whitespace should be ignored
-Any other block of contiguous whitespace should be treated as a single space
-non-alphanumeric character should be ignored, white space should be retained
Duplicates must also be filtered - if two passages are considered equal with respect to the comparison rules listed above, only the shortest should be retained.
If they are also the same length, the earlier one in the input sequence should be kept. The retained passages should be output in their original form (identical to the input passage), and in the same order.
Input:
For each test case a single line comprising the passages (strings) to be processed, delimited by | characters. The | characters are not considered part of any passage.
Output:
A single line of filtered passages in the same |-delimited format.
Test 1
Test Input
Download Test Input
IBM cognitive computing|IBM "cognitive" computing is a revolution| ibm cognitive computing|'IBM Cognitive Computing' is a revolution?
Expected Output
Download Test Output
IBM "cognitive" computing is a revolution
Test 2
Test Input
Download Test Input
"Computer Science Department"|Computer-Science-Department|the "computer science department"
Expected Output
Download Test Output
Computer-Science-Department|the "computer science department"