Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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" 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions