DWITE Online Computer Programming Contest
December 2007
Problem 2
There's An Essay In My Code

There's an issue of plagiarism in every academic course, but it seems to be more common in computer science classes, possibly because it's not as apparent to spot as, for example, in an English essay. Though, a typical program still contains enough English text in string literals and comments to be the equivalent of a small essay. The task is to extract just such text from a block of code.

The input file DATA2.txt will contain five lines of input of valid ASCII text. String literals will be in either " or ' quotes. Comments will be C++ style: /* inline */ and // end of line. There will be no nested /* */ comments.

The output file OUT2.txt will contain five lines, aggregating the text found in the matching lines of the input. The text is defined as any string literal and any comment. Blocks of text found in a line should be joined together by spaces.

Note: No nested /* */ comments means there will not be a line of input similar to /* /* */ */. Comments found inside a string are deemed to be a part of the string. Strings found inside a comment will be deemed to be a part of the comment. One type of a string literal can contain another. See sample input for clarifications.

Sample Input:
function my_badly_named_function(); //this is a comment
puts "some string content" //and comments
go_go("gadget" /* notice extra spaces */); //"for inline comment"
"nested 'strings'"
/*just some //comments*/
Sample Output:
this is a comment
some string content and comments
gadget  notice extra spaces  "for inline comment"
nested 'strings'
just some //comments