MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / remove_word

Function remove_word

backtracking/crossword_puzzle_solver.py:59–79  ·  view source on GitHub ↗

Remove a word from the given position. >>> puzzle = [ ... ['w', '', '', ''], ... ['o', '', '', ''], ... ['r', '', '', ''], ... ['d', '', '', ''] ... ] >>> remove_word(puzzle, 'word', 0, 0, True) >>> puzzle [['', '', '', ''], ['', '', '', ''],

(
    puzzle: list[list[str]], word: str, row: int, col: int, vertical: bool
)

Source from the content-addressed store, hash-verified

57
58
59def remove_word(
60 puzzle: list[list[str]], word: str, row: int, col: int, vertical: bool
61) -> None:
62 """
63 Remove a word from the given position.
64
65 >>> puzzle = [
66 ... ['w', '', '', ''],
67 ... ['o', '', '', ''],
68 ... ['r', '', '', ''],
69 ... ['d', '', '', '']
70 ... ]
71 >>> remove_word(puzzle, 'word', 0, 0, True)
72 >>> puzzle
73 [['', '', '', ''], ['', '', '', ''], ['', '', '', ''], ['', '', '', '']]
74 """
75 for i in range(len(word)):
76 if vertical:
77 puzzle[row + i][col] = ""
78 else:
79 puzzle[row][col + i] = ""
80
81
82def solve_crossword(puzzle: list[list[str]], words: list[str]) -> bool:

Callers 1

solve_crosswordFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected