I'm a little surprised not to see any mention of the Levenshtein Distance[0] here. It's the standard way of comparing strings, there are libraries to do it[1], and it seems to be exactly what's happening here.
There's value in deriving code from scratch to understand the algorithm and the language, but not to mention it at all seems a little odd.
Since you specifically mentioned DNA similarity and not strings in general, I assume you want to align the sequences rather than just the Levenshtein distance between them...
If that is the case, I recommend using Biopython (https://biopython.org/) for alignments. There are modules for pairwise sequence alignments both global and local alignments.
2 comments
[ 1.4 ms ] story [ 22.6 ms ] threadThere's value in deriving code from scratch to understand the algorithm and the language, but not to mention it at all seems a little odd.
[0] https://en.wikipedia.org/wiki/Levenshtein_distance
[1] https://duckduckgo.com/?q=Levenshtein+distance+python+librar...