How far apart are two words? Count the smallest number of single-letter edits — insert, delete, or substitute — that turns one into the other. ‘kitten’ becomes ‘sitting’ in exactly three. A grid finds that cheapest path, and it is the honest measure of a crossing. Slide along the edit path.
Fill a grid where cell (i,j) is the edit distance between the first i letters of A and first j of B: d[i][j] = min(delete, insert, substitute), the substitute costing 0 if the letters match. The bottom-right corner is the answer, and tracing back gives the actual edits. A fail-loud self-check throws unless d(‘kitten’,‘sitting’)=3, d(x,x)=0, and the triangle inequality d(a,c) ≤ d(a,b)+d(b,c) holds — a true metric on the gap between strings.
Uniform edit costs here; real spell-checkers weight edits (keyboard adjacency, phonetics) and add transposition (Damerau). The dynamic-programming distance and its metric properties are exact.