http://qs321.pair.com?node_id=1199128

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone!
I am in need on an implementation of the Longest-Common-Substring problem, but with one addition - that one can allow for N mis-matches. I found several threads in the Monastery, but they all seem to work for exact matches - no miscmatches allowed.
Anybody knows where to look for?
Many thanks!
  • Comment on Longest common substring with N mismatches

Replies are listed 'Best First'.
Re: Longest common substring with N mismatches
by poj (Abbot) on Sep 11, 2017 at 17:36 UTC

      It was buggy, but now it's fixed. Also, it now returns all matches instead of just one (still in O(M*N) time).

        Ikegami, that is indeed precisely what I was after.
        One small question, if you may:
        Is there a way that I can know which part (beg-end) of each of the two strings I provide is covered by the LCSS?
        Many thanks!
Re: Longest common substring with N mismatches
by tybalt89 (Monsignor) on Sep 11, 2017 at 16:35 UTC

    Please define "mismatch". Does it include inserts and deletes and replaces? Or only replaces?

      Replaces only.
Re: Longest common substring with N mismatches
by LanX (Saint) on Sep 11, 2017 at 16:46 UTC
      All I am asking is if anyone knows of such a module or implementation. I read threads like 994837, 608174, 249239, 145608, but they all work with exact matching. And I was hoping that someone would perhaps know of a module or something that can allow for some mismatches instead of requiring exact matches.
Re: Longest common substring with N mismatches
by hdb (Monsignor) on Sep 12, 2017 at 06:29 UTC