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

Function dfs

matrix/matrix_based_game.py:146–157  ·  view source on GitHub ↗
(row_n: int, column_n: int)

Source from the content-addressed store, hash-verified

144 if (color := matrix_g[column][row]) != "-":
145
146 def dfs(row_n: int, column_n: int) -> None:
147 if row_n < 0 or row_n >= size or column_n < 0 or column_n >= size:
148 return
149 if (row_n, column_n) in visited:
150 return
151 visited.add((row_n, column_n))
152 if matrix_g[row_n][column_n] == color:
153 repeated.add((row_n, column_n))
154 dfs(row_n - 1, column_n)
155 dfs(row_n + 1, column_n)
156 dfs(row_n, column_n - 1)
157 dfs(row_n, column_n + 1)
158
159 dfs(column, row)
160

Callers 1

find_repeatFunction · 0.70

Calls 1

addMethod · 0.45

Tested by

no test coverage detected