A friend of mine was talking about a word game she liked to play where you try to convert one word to another (they have the same number of letters) by switching one letter at a time, where each iteration produces a real word.
Example:
MOON --> WOLF
GOON
GOOF
GOLF
WOLF
I figured it'd be a fun little project to write a program to generate solutions, and taking it further, given 2 words, determine if a solution exists and the number of iterations in optimal solution.
Problem is I'm having trouble finding free word lists that I can easily access programmatically. I'm also thinking about using this as an excuse to learn Python, so it'd be great if anyone knows of free word lists and pointers on how to parse and access it from Python. The algorithm for figuring out how to find an optimal path I'll work on my own.
Options:
#4
is the one I used for my own Python experiment into word games, and it worked nicely.
For bonus points, here's something to get you started on your word program:
import re startwith = "MOON" endwith = "GOLF" cklength = re.compile('.{' + str(len(startwith)) + '}(\n)?$', re.I) filename = "C:/dict.txt" words = set(x.strip().upper() for x in open(filename) if x.match(cklength))
Words will then be a set of all 4 letter words in the dictionary. You can do your logic from there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With