Edit distance

A robot typed “cat” on a sign that should say “cuts”. It can edit one letter per move. How few moves does it need?

One move inserts, deletes or replaces one symbol. Matching symbols stay as they are.

Each cell gives the edits needed for two prefixes. The symbol ε means an empty string.

Words of lengths m and n use (m + 1) × (n + 1) cells. Each cell takes constant time.