Place a word at the given position. >>> puzzle = [ ... ['', '', '', ''], ... ['', '', '', ''], ... ['', '', '', ''], ... ['', '', '', ''] ... ] >>> place_word(puzzle, 'word', 0, 0, True) >>> puzzle [['w', '', '', ''], ['o', '', '', ''], ['r',
(
puzzle: list[list[str]], word: str, row: int, col: int, vertical: bool
)
| 34 | |
| 35 | |
| 36 | def place_word( |
| 37 | puzzle: list[list[str]], word: str, row: int, col: int, vertical: bool |
| 38 | ) -> None: |
| 39 | """ |
| 40 | Place a word at the given position. |
| 41 | |
| 42 | >>> puzzle = [ |
| 43 | ... ['', '', '', ''], |
| 44 | ... ['', '', '', ''], |
| 45 | ... ['', '', '', ''], |
| 46 | ... ['', '', '', ''] |
| 47 | ... ] |
| 48 | >>> place_word(puzzle, 'word', 0, 0, True) |
| 49 | >>> puzzle |
| 50 | [['w', '', '', ''], ['o', '', '', ''], ['r', '', '', ''], ['d', '', '', '']] |
| 51 | """ |
| 52 | for i, char in enumerate(word): |
| 53 | if vertical: |
| 54 | puzzle[row + i][col] = char |
| 55 | else: |
| 56 | puzzle[row][col + i] = char |
| 57 | |
| 58 | |
| 59 | def remove_word( |