Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Longest common substring with N mismatches

by poj (Abbot)
on Sep 11, 2017 at 17:36 UTC ( [id://1199142]=note: print w/replies, xml ) Need Help??


in reply to Longest common substring with N mismatches

Anybody knows where to look for?

ikegami replied to a similar question here https://stackoverflow.com/questions/6258922/efficient-substring-matching-in-perl

poj

Replies are listed 'Best First'.
Re^2: Longest common substring with N mismatches
by ikegami (Patriarch) on Sep 11, 2017 at 21:41 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!

        Just change what you put into @solutions. Replace

        $i-$l+1

        with

        # Start of match in first string # End of match in first string [ $i-$l+1, $i+1 ]

        or

        # Start of match in first string # End of match in first string # Start of match in second string # End of match in second string [ $i-$l+1, $i+1, $j-$l+1, $j+1 ]

        or

        # Start of match in first string # Start of match in second string # Length of match [ $i-$l+1, $j-$l+1, $l ]

        and remove

        map { substr($s, $_, $best_l) }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1199142]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-28 13:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found