Skip to content

Finds the shortest path between two words by changing one letter at a time. It reads a dictionary of words from a file and creates a graph where each node represents a word, and edges connect words that differ by one letter.

Notifications You must be signed in to change notification settings

AdamZieman/word-ladder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Word Ladder

This program allows you to find a word ladder between two given words using breadth-first search. A word ladder is a sequence of words formed by changing one letter at a time, where each intermediate word in the sequence is a valid word defined by a word bank.

How It Works

This program uses a graph to represent a dictionary of words. Each word is represented as a node in the graph, and two nodes are connected by an edge if the words differ by exactly one letter. The breadth-first search algorithm is used to find the shortest path from the starting word to the ending word in this graph.

The program first checks if the words are of the same character length. It then reads in the file containing a list of words for that character length. Next, it constructs a graph of nodes representing these words, and finds the shortest path from the starting word to the ending word, using the breadth-first seach algorithm.

FoundWordLadder

Limitations

This program has some limitations:

  • Both input words must have the same character length.
  • It only works for words contained in the word bank.
    • A word bank exists for each character length between 3 and 9, inclusively.
    • A default word bank exists for character lengths, outside of the above range.
  • It only finds the shortest path between two words, if there is one.

NoFoundWordLadder WordLengthNotSame

About

Finds the shortest path between two words by changing one letter at a time. It reads a dictionary of words from a file and creates a graph where each node represents a word, and edges connect words that differ by one letter.

Topics

Resources

Stars

Watchers

Forks