word_ladder package¶
Submodules¶
word_ladder.word_ladder module¶
-
class
word_ladder.word_ladder.Graph(words)¶ Bases:
objectRepresents an un-weigthed graph structure with connected words
Parameters: words ( iterable) – Words to build the graph with-
build(all_lengths=True)¶ Build the graph
Parameters: all_lengths ( bool, optional) – Define if the graph should connect words with different lengthsReturns: dictwith the graph structure
-
-
class
word_ladder.word_ladder.WordLadder(dictionary, start=None, end=None)¶ Bases:
objectRepresents a word ladder
Parameters: - dictionary (
listorstr) – Feed with words - start (
str, optional) – The starting word, Defaults to None - end (
str, optional) – The ending word, Defaults to None
-
find_path(start=None, end=None, all_paths=False)¶ Find the word ladder path
Parameters: - start (
str, optional) – The starting word, Defaults to None - end (
str, optional) – The ending word, Defaults to None - all_lengths (
bool, optional) – Define if the graph should connect words with different lengths
Raises: WordsNotDefined– If any of the words is NoneReturns: With the word’s path or None
Return type: (
list)- start (
-
graph¶ Holds an instance of
Graphwith the dictionary wordsReturns: The graph memoized instance Return type: ( Graph)
-
words_has_same_length()¶ Compare length of start and end words
Returns: ( boolorNone) True, False or None)
- dictionary (