This isn't your homework, is it? Anyhow, the [Needleman–Wunsch algorithm] (https://en.m.wikipedia.org/wiki/Needleman–Wunsch_algorithm) may help here.
– RenéDec 25 '16 at 17:32
I suggest you read about the [LCS problem](https://en.wikipedia.org/wiki/Longest_common_subsequence_problem). [Here's](https://rosettacode.org/wiki/Longest_common_subsequence#Python) a site with some basic implementation of that algorithm.
– Shachar OhanaDec 25 '16 at 17:30