Word transformation sequence
Your task
Given a begin word, an end word, and a dictionary of equal-length lowercase words, you may transform one word into another by changing exactly one letter at a time, and every intermediate word must be in the dictionary. Return the number of words in the shortest transformation sequence from begin to end, inclusive of both endpoints. The begin word need not be in the dictionary, but the end word must be. Return 0 if no transformation is possible. All words have length 1..10 and the dictionary has at most 5000 words.
Examples
ladder_length(begin: str, end: str, words: list[str]) -> intExample 1
Input
ladder_length("hit", "cog", ["hot", "dot", "dog", "lot", "log", "cog"])Output
5