Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
recursively paint over solution in Clear category for Can You Pass? by kdim
def can_pass(matrix, first, second):
def paint(i, j) -> None: # recursive paint
if m[i][j] != v or m[i][j] == '': # end of recursion
return
m[i][j] = '' # paint
for d in (1, -1):
if -1 < i+d < len(m):
paint(i + d, j) # paint neibor
if -1 < j+d < len(m[0]):
paint(i, j + d) # paint neibor
return
m = [list(i) for i in matrix]
i, j, p, q = *first, *second
v = m[i][j]
paint(*first)
return m[p][q] == ''
Jan. 23, 2021
Comments: