I need to find the edit distance between a word and its sorted word (ex: apple and aelpp), using only insertions and deletions recursively.
I have found some sources that used insertions, deletions, and substitutions, but I am not sure how to only use insertion and deletion.
This is the code I found:
def ld(s, t):
if not s: return len(t)
if not t: return len(s)
if s[0] == t[0]: return ld(s[1:], t[1:])
l1 = ld(s, t[1:])
l2 = ld(s[1:], t)
l3 = ld(s[1:], t[1:])
return 1 + min(l1, l2, l3)
What edits would need to be made to only find the number of insertions and deletions?