Update, October 2, 2025: Appreciation to everyone who participated in this challenge! The correct length of the word ladders is as follows:
[stone, money] [11]
[bread, crumb] [11]
[smile, giant] [11]
[apple, zebra] [Not possible; sorry for the trick]
[other, night] [17]
[bread, blood] [4]
[black, white] [8]
The exercise was successfully completed by 23 out of 26 entries (88%).
Congratulations to the following users for successfully solving the challenge: maraca, mdyousufniaz, gimix, Violet Rosenzweig, Anon Coward, sehe, tom.barthelmeh, Nanigashi, Burkhard, Harshank Bansal, Xirtaminu, LukasKroess, choroba, Greg, davo36, Joan, 啊鹿Dizzyi, gee3107, Remy, Christian, chatours, André, chrslg
Impressive to see the discussions about algorithm efficiency in the entries!
Original Challenge post
For today’s challenge, we will explore word ladders.
A word ladder is a sequence of words where each word differs from the previous one by exactly one letter, and all words must be valid dictionary words.
For example, if we want to transform the word ‘money’ to ‘bones’, one possible word ladder would be ‘money’ -> ‘honey’ -> ‘honed’ -> ‘boned’ -> ‘bones’. This ladder has 5 words.
The Challenge
Using this dictionary of five-letter words, create a program to determine the shortest word ladder between two words.
Using your program, determine the length of the shortest possible word ladder for this test set of 7 pairs:
[stone, money]
[bread, crumb]
[smile, giant]
[apple, zebra]
[other, night]
[bread, blood]
[black, white]
This challenge will be a pass/fail challenge (all correct/valid responses will be recognized).
Key dates
You have two weeks from the date this challenge is posted to submit your entry.
September 18: Challenge goes live
October 2: Deadline for submitting challenge entries for recognition. Winners will be announced on this date or soon after.
How to Submit
Enter your submission in the text box below.
Your submission should include:
The length of the word ladders for each of the pairs in the test set. For this exercise, the length is the number of unique words in the ladder (including the starting and ending words).
The word ladders you produced
The code you have written
[Optional] Anything you learned or any interesting challenges you faced while coding
Your entry is not permitted to be written by AI. For any feedback on this Challenge, please head over to the Meta post.
I used python.
My first attempt was recursively listing all words that are off by 1 letter from every word found so far. For example, offby1('stone') -> ['atone', 'shone', 'scone', 'store', 'stove', 'stole', 'stoke', 'stoae', 'stony']. Check if 'money' is in those and if not, make a list of all offby1(word) for every word in the candidates (excluding from the output any word found so far, to prevent longer paths to the same word and cycles; I made a list called
exclude; to use it across functions I put everything in a class). This recursive technique took far too long to run.I printed the paths as they were being created to find why. It would take a path as far as possible until the dictionary exhausted (['bread', 'dread', 'dream', 'cream', 'creak', 'wreak', 'wreck', ...]). I'd much rather it check paths of length 1, then paths of length 2, and so on, not just for speed but also so that when it returns a solution it's guaranteed to be the shortest path.
I found a way to implement this: list every path of a given length (starting with [[w1],]), then use offby1() on the final word in each path to list all paths with one more word (and return early if target found). Unfortunately, this stores increasingly long lists; and when there is no valid path, such as with apple -> zebra, it could still take very long checking all paths possible from apple. Altogether it took my laptop 19.5 minutes to run. Definitely not the best it could be.
Output: