@@ -66,7 +66,7 @@ def insert_north(self, word: str, rows: list[int], cols: list[int]) -> None:
66
66
self .board [row - i ][col ] = word [i ]
67
67
return
68
68
69
- def insert_north_east (self , word : str , rows : list [int ], cols : list [int ]) -> None :
69
+ def insert_northeast (self , word : str , rows : list [int ], cols : list [int ]) -> None :
70
70
"""
71
71
>>> ws = WordSearch(WORDS, 3, 3)
72
72
>>> ws.insert_north_east("cat", [2], [0])
@@ -99,7 +99,7 @@ def insert_north_east(self, word: str, rows: list[int], cols: list[int]) -> None
99
99
self .board [row - i ][col + i ] for i in range (word_length )
100
100
]
101
101
if all (letter is None for letter in letters_diagonal_left ):
102
- # Successful, insert the word north
102
+ # Successful, insert the word northeast
103
103
for i in range (word_length ):
104
104
self .board [row - i ][col + i ] = word [i ]
105
105
return
@@ -131,12 +131,12 @@ def insert_east(self, word: str, rows: list[int], cols: list[int]) -> None:
131
131
# to the right of the column that will be overwritten
132
132
letters_left = [self .board [row ][col + i ] for i in range (word_length )]
133
133
if all (letter is None for letter in letters_left ):
134
- # Successful, insert the word north
134
+ # Successful, insert the word east
135
135
for i in range (word_length ):
136
136
self .board [row ][col + i ] = word [i ]
137
137
return
138
138
139
- def insert_south_east (self , word : str , rows : list [int ], cols : list [int ]) -> None :
139
+ def insert_southeast (self , word : str , rows : list [int ], cols : list [int ]) -> None :
140
140
"""
141
141
>>> ws = WordSearch(WORDS, 3, 3)
142
142
>>> ws.insert_south_east("cat", [0], [0])
@@ -153,13 +153,13 @@ def insert_south_east(self, word: str, rows: list[int], cols: list[int]) -> None
153
153
word_length = len (word )
154
154
# Attempt to insert the word into each row and when successful, exit
155
155
for row in rows :
156
- # Check if there is space for the word above the row
156
+ # Check if there is space for the word below the row
157
157
if word_length + row > self .height :
158
158
continue
159
159
160
160
# Attempt to insert the word into each column
161
161
for col in cols :
162
- # Check if there is space to the right of the word as well as above
162
+ # Check if there is space to the right of the word as well as below
163
163
if word_length + col > self .width :
164
164
continue
165
165
@@ -169,7 +169,7 @@ def insert_south_east(self, word: str, rows: list[int], cols: list[int]) -> None
169
169
self .board [row + i ][col + i ] for i in range (word_length )
170
170
]
171
171
if all (letter is None for letter in letters_diagonal_left ):
172
- # Successful, insert the word north
172
+ # Successful, insert the word southeast
173
173
for i in range (word_length ):
174
174
self .board [row + i ][col + i ] = word [i ]
175
175
return
@@ -206,7 +206,7 @@ def insert_south(self, word: str, rows: list[int], cols: list[int]) -> None:
206
206
self .board [row + i ][col ] = word [i ]
207
207
return
208
208
209
- def insert_south_west (self , word : str , rows : list [int ], cols : list [int ]) -> None :
209
+ def insert_southwest (self , word : str , rows : list [int ], cols : list [int ]) -> None :
210
210
"""
211
211
>>> ws = WordSearch(WORDS, 3, 3)
212
212
>>> ws.insert_south_west("cat", [0], [2])
@@ -223,13 +223,13 @@ def insert_south_west(self, word: str, rows: list[int], cols: list[int]) -> None
223
223
word_length = len (word )
224
224
# Attempt to insert the word into each row and when successful, exit
225
225
for row in rows :
226
- # Check if there is space for the word above the row
226
+ # Check if there is space for the word below the row
227
227
if word_length + row > self .height :
228
228
continue
229
229
230
230
# Attempt to insert the word into each column
231
231
for col in cols :
232
- # Check if there is space to the right of the word as well as above
232
+ # Check if there is space to the left of the word as well as below
233
233
if word_length > col + 1 :
234
234
continue
235
235
@@ -239,7 +239,7 @@ def insert_south_west(self, word: str, rows: list[int], cols: list[int]) -> None
239
239
self .board [row + i ][col - i ] for i in range (word_length )
240
240
]
241
241
if all (letter is None for letter in letters_diagonal_left ):
242
- # Successful, insert the word north
242
+ # Successful, insert the word southwest
243
243
for i in range (word_length ):
244
244
self .board [row + i ][col - i ] = word [i ]
245
245
return
@@ -271,12 +271,12 @@ def insert_west(self, word: str, rows: list[int], cols: list[int]) -> None:
271
271
# to the left of the column that will be overwritten
272
272
letters_left = [self .board [row ][col - i ] for i in range (word_length )]
273
273
if all (letter is None for letter in letters_left ):
274
- # Successful, insert the word north
274
+ # Successful, insert the word west
275
275
for i in range (word_length ):
276
276
self .board [row ][col - i ] = word [i ]
277
277
return
278
278
279
- def insert_north_west (self , word : str , rows : list [int ], cols : list [int ]) -> None :
279
+ def insert_northwest (self , word : str , rows : list [int ], cols : list [int ]) -> None :
280
280
"""
281
281
>>> ws = WordSearch(WORDS, 3, 3)
282
282
>>> ws.insert_north_west("cat", [2], [2])
@@ -299,7 +299,7 @@ def insert_north_west(self, word: str, rows: list[int], cols: list[int]) -> None
299
299
300
300
# Attempt to insert the word into each column
301
301
for col in cols :
302
- # Check if there is space to the right of the word as well as above
302
+ # Check if there is space to the left of the word as well as above
303
303
if word_length > col + 1 :
304
304
continue
305
305
@@ -309,7 +309,7 @@ def insert_north_west(self, word: str, rows: list[int], cols: list[int]) -> None
309
309
self .board [row - i ][col - i ] for i in range (word_length )
310
310
]
311
311
if all (letter is None for letter in letters_diagonal_left ):
312
- # Successful, insert the word north
312
+ # Successful, insert the word northwest
313
313
for i in range (word_length ):
314
314
self .board [row - i ][col - i ] = word [i ]
315
315
return
0 commit comments