word_ladder package¶
Submodules¶
word_ladder.word_ladder module¶
-
class
word_ladder.word_ladder.
Graph
(words)¶ Bases:
object
Represents 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: dict
with the graph structure
-
-
class
word_ladder.word_ladder.
WordLadder
(dictionary, start=None, end=None)¶ Bases:
object
Represents a word ladder
Parameters: - dictionary (
list
orstr
) – 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
Graph
with the dictionary wordsReturns: The graph memoized instance Return type: ( Graph
)
-
words_has_same_length
()¶ Compare length of start and end words
Returns: ( bool
orNone
) True, False or None)
- dictionary (