Edit Distance — Fill the Grid, Trace the Alignment

The DP cell (i, j) is the edit distance between the first i chars of A and first j chars of B. Watch the grid fill, then the traceback color each step as match / substitute / insert / delete.

step 0

Edit-distance DP grid

being filled match substitute insert delete

Alignment & edit script

Recovered by traceback from the bottom-right corner:
 
 
Edit distance = ?
Press Step to begin. Phase 1 fills the grid with the three-way minimum; phase 2 traces back the cheapest path to recover the alignment.
Self-contained visualization. Unit-cost Levenshtein: insert = delete = substitute = 1, match = 0. The diagonal move is a match (free) or substitution; the up move is a delete; the left move is an insert. See junior.md for the fill rule and middle.md for the "edit distance = shortest path in this grid" view.