A spell-checker suggests the dictionary word closest to what was typed. Write typos(a, b): the fewest single-letter fixes that turn word a into word b, where a fix is replacing one letter, inserting one, or deleting one.
Someone typed “kiten”. A spell-checker compares it with every dictionary word and suggests the one with the fewest typos. Counting letter by letter gets it wrong: one missing letter shifts everything after it. The goal is a list like the one it ends on. Your typos(a, b) counts the fixes.
typos(a, b)| a | the word that was typed, e.g. "kiten" | e.g. "cat" |
| b | a dictionary word to compare it with, e.g. "kitten" | e.g. "cat" |
| returns | the fewest single-letter fixes (replace one letter, insert one, or delete one) that turn a into b | |