Problem. Given begin_word, end_word and a word_list, return the number of words in the shortest transformation
sequence from begin to end, where each step changes exactly one letter and every word after the first must be in the list.
Return 0 if there's none.
begin = "hit", end = "cog", word_list = ["hot", "dot", "dog", "lot", "log", "cog"]
hit → hot → dot → dog → cog → 5
Words are nodes; two words are joined when they differ in exactly one letter. "Fewest steps" is BFS (lesson 11.1). The real work is building the edges cheaply: with 5,000 words, checking every pair is 12.5 million comparisons.
ML context. "Words one edit apart" is the neighbourhood structure behind spelling correction, candidate generation for fuzzy label matching (lesson 12.15 computes full edit distances), and data augmentation with near-miss tokens. The wildcard-bucket trick (Optimisation B) is a tiny version of how fuzzy search indexes group strings by shared patterns so that similar strings meet without comparing all pairs.