Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Longest common substring with N mismatches

by Anonymous Monk
on Sep 12, 2017 at 09:49 UTC ( #1199184=note: print w/replies, xml ) Need Help??


in reply to Re^2: Longest common substring with N mismatches
in thread Longest common substring with N mismatches

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!
  • Comment on Re^3: Longest common substring with N mismatches

Replies are listed 'Best First'.
Re^4: Longest common substring with N mismatches
by ikegami (Pope) on Sep 12, 2017 at 15:51 UTC

    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) }
      Hi ikegami! Many thanks! I forgot to post it here, I think I solved my problem with the String::Approx module (since I always had just 1 mismatch). But I will try your approach as well, it seems to be more solid anyway...
      Many thanks again!

        Not quite. "Word" and "world" have one mismatch according to that module.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1199184]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2017-10-21 03:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (269 votes). Check out past polls.

    Notices?