How to compute a delta: the difference between lists of strings

Vito De Tullio vito.detullio at gmail.com
Sat May 5 12:16:40 EDT 2012


J. Mwebaze wrote:

> This is out of curiosity, i know this can be done with python diffllib
> module, but been figuring out how to compute the delta, Consider two lists
> below.
> 
> s1 = ['e', 'f', 'g', 'A', 'B', 'C', 'D', 'C']
> s2 =['e', 'A', 'B', 'f', 'g', 'C', 'D', 'z']
> 
> This is the result should be
> 
> ['  e', '+ A', '+ B', '  f', '  g', '- A', '- B', '  C', '  D', '- C', '+
> z']
> 
> ideas on how to approach this.. ?

http://en.wikipedia.org/wiki/Longest_common_subsequence_problem

-- 
ZeD





More information about the Python-list mailing list