❔ Troubles getting all Largest Common Subsequences of two strings.
For fun trying to write a system to take differential backups of strings.
The backbone is this method I wrote, which should find all LCSs between two strings:
14 Replies
Which returns the start and end indices of where the substring is present in
_new
and the start index of where the substring is present in _old
As a test I am running it with the following parameters:
_new = "Old New Old"
_old = "Old Old"`
If you get the substrings in the ranges returned by the function the LCSs are:
Old
and
Old
(One with a space before, one after)
I would like for it to only return
Old and
Old (Only one with the space, doesn't matter which.)
I've been unable to tweak the overlap removal bit to get the desired result
Desired output:
|Old|, | Old| or
|Old |, |Old|
Current output:
|Old |, | Old|``
(With vertical bars representing where the substrings end to make the spaces clearFYI you can make the code clearer by using named tuples or records. Right now it's kinda hard to figure the code out because of parts that mean nothing, like
o
and .Item1
(also, _name
is used for private fields, neither parameters nor local variables should start with an underscore)Ah, nice. Never heard of a named tuple! Didn't want to use a struct for something I was going to use once.
You use it multiple times, though
Only did this because
new
is already a keyword lolSo it does warrant a struct or a record
@new
thenAh
Cool
Angius
REPL Result: Success
Compile: 370.253ms | Execution: 27.959ms | React with ❌ to remove this embed.
There
And sorry for the ping, Int lol
Poor guy lmao
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.