User:Nils Grimsmo/LCS diff

The following example uses the functions from Longest common subsequence problem, with an example from diff.

X = [ "This part of the document has stayed", "the same from version to version.", "",    "This paragraph contains text that is", "outdated - it will be deprecated and", "deleted in the near future.", "",    "It is important to spell check this", "dokument. On the other hand, a misspelled", "word isn't the end of the world.", ] Y = [ "This is an important notice! It should", "therefore be located at the beginning of", "this document!", "",    "This part of the document has stayed", "the same from version to version.", "",    "It is important to spell check this", "document. On the other hand, a misspelled", "word isn't the end of the world. This", "paragraph contains important new", "additions to this document.", ] C = LCS(X, Y) printDiff(C, X, Y, len(X), len(Y))

It prints the following:

+ This is an important notice! It should + therefore be located at the beginning of + this document! +   This part of the document has stayed the same from version to version. - - This paragraph contains text that is - outdated - it will be deprecated and - deleted in the near future. It is important to spell check this - dokument. On the other hand, a misspelled - word isn't the end of the world. + document. On the other hand, a misspelled + word isn't the end of the world. This + paragraph contains important new + additions to this document.