Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Can You Pass? by TovarischZhukov
def find(matrix, checked, first, second, current):
if matrix[current[0]][current[1]] == matrix[first[0]][first[1]] and current not in checked:
checked.append(current)
return current == second or \
find(matrix, checked, first, second, (min(current[0]+1, len(matrix)-1), current[1])) or \
find(matrix, checked, first, second, (max(current[0]-1, 0), current[1])) or \
find(matrix, checked, first, second, (current[0], min(current[1]+1, len(matrix[0])-1))) or \
find(matrix, checked, first, second, (current[0], max(current[1]-1, 0)))
return False
def can_pass(matrix, first, second):
checked = []
return find(matrix, checked, first, second, first)
Dec. 17, 2015