Problem:
I've coded a Levenshtein String Editing program that appears to work correctly to me, but apparently yields the wrong answer. I think I misunderstand how the Editing Distance is calculated.
Comparison
for the strings superca and antigravitational, here's a comparison of the last two rows
Mine:
a n t i g r a v i t a t i o n a l
c 6 6 6 6 6 6 6 6 7 8 9 10 11 12 13 14 15 16
a 7 6 7 7 7 7 7 6 7 8 9 9 10 11 12 13 13 14
Others:
a n t i g r a v i t a t i o n a l
c 6 6 6 6 6 6 6 6 7 8 9 10 11 12 13 14 15 16
a 7 6 7 7 7 7 7 6 7 8 9 9 10 11 12 13 14 15
In my calculation, you can see that because the last "a" in antigravitational matches the "a" in superca so I gave it a value of 13 since the number directly to the left is a 13. Therefore, the cost is 0.
In other calculations, it appears that people are still adding a cost in these situations. As you can see in the other example, they placed a 14 where I placed the 13 resulting in the final Editing Distance of 15 (as opposed to my 14).
Am I right and everyone else is wrong (unlikely), or am I missing a step?
I found my own answer after a few YouTube videos.
My Mistake
My instructions stated "If the letters you are comparing match, set the cost to 0 and copy the minimum(left, diagonal, above). If they do not match, add 1.
The Correction
So the instructions were slightly inaccurate. In cases where the letters match you should ALWAYS copy the diagonal with no cost, regardless of what the value to the left and the value above are.