LearnPy Hub
← Arena
AdvancedRating 1800

Word Ladder

Change one letter at a time to go from the start word to the end word, using only words in the dictionary. Print the number of words in the shortest ladder (including both ends), or 0.

Input

start end, then a line of dictionary words.

Output

A number.

Sample 1

Input
hit cog
hot dot dog lot log cog
Output
5

Sample 2

Input
hit cog
hot dot dog lot log
Output
0
solution.py
Output appears here
Word Ladder · Python Arena problem · LearnPy Hub