Husk, (削除) 10 (削除ここまで) 9 bytes
Lṁ-→FnmṖ1
Inspired by ais523's Brachylog solution, finds the longest common (not necessarily contiguous) subsequence and subtracts it from each string.
(削除) I don't like having to repeat Now I'm happy :)Ṗ twice and having to explicitly refer to the two arguments 1 and 3, but I couldn't find any shorter alternative. (削除ここまで)
Explanation
Lṁ-→FnmṖ1 Input: a list containing the two strings
Ṗ Get all possible subsequences
m 1 for each string
Fn Keep only the common ones
→ Get the last one (which will be the longest)
- and subtract it
ṁ from each of the inputs, then concatenate the remaining characters
L Find the length of this
Subtracting the longest common substring for each input results in the lists of characters that need to be deleted/inserted. We concatenate these two lists and get the length to calculate the edit distance.
- 12.9k
- 1
- 33
- 63