We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0dd2b8d commit 0ac14b2Copy full SHA for 0ac14b2
backtracking/word_search_path.py
@@ -65,16 +65,19 @@ def get_word_path(
65
>>> # 1. Find "CATS" starting at (0,0). Initial key is 0.
66
>>> get_word_path(board, "CATS", 0, 0, 0, {0}, [])
67
[(0, 0), (0, 1), (0, 2), (1, 2)]
68
-
69
- >>> # 2. Find "BC" starting at (2,1).
+
+ >>> # 2. Find "BC" starting at (2,1).
70
>>> # Key for (2,1) in 3x3 is: (3 * 3 * 2) + 1 = 19
71
>>> get_word_path(board, "BC", 2, 1, 0, {19}, [])
72
[(2, 1), (2, 2)]
73
74
- >>> # 3. Partial search: current_path already has (0,0), looking for "ATS" starting at (0,1)
75
- >>> # Key for (0,1) is 1. Visited includes the 'C' at key 0.
+ >>> # 3: Partial search with existing path
76
>>> get_word_path(board, "ATS", 0, 1, 0, {0, 1}, [(0, 0)])
77
78
+ >>> # 4. Failure case: First letter doesn't match current cell
79
+ >>> get_word_path(board, "DOG", 0, 0, 0, {0}, []) is None
80
+ True
81
"""
82
83
if board[row][column] != word[word_index]:
0 commit comments