Find the shortest path between two four letter words, where two words are considered adjacent if one can be obtained from the other by changing a single letter.
Simply clone the repository and build using make
:
git clone https://github.com/alexrutar/wordpath
cd wordpath && make
This will probably work with most mildly modern versions of gcc.
The main subcommand search
determines the distance between words.
For example, to find the distance between the words "real" and "fake", run:
$ ./wordpath search real fake
real
heal
hell
hall
hale
hake
fake
If there is no path, the program returns an error:
$ ./wordpath search good evil
There is no path from "good" to "evil".
(return code 1)
Get the adjacent words in the word list:
$ ./wordpath adjacent soup
coup
soap
soul
sour
Get a word which has maximum distance from the given word:
$ ./wordpath farthest soup
axle
Get the isolated vertices (words with no neighbours):
$ ./wordpath isolated
afro
agog
ague
...
zori
zuni
Get the words which are the maximum (finite) distance apart (this is very slow):
$ ./wordpath diameter
...
Max distance 16, from "abut" to "inca".
The dictionary used is the file four.txt which is extracted from the word list from the Project Gutenburg Website.
Note that this program will work with any word list - the words do not need to have exactly four letters.
Feel free to modify this source if there are words you do not agree with, or even use your own text source.
If you do make changes, ensure that you first delete the object file graph
.
The text file must be sorted alphabetically for the program to work.