Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Radiation search solution in Uncategorized category for Radiation Search by capback250
def recursion(matrix, i, j, value):
if len(matrix) > i >= 0 and 0 <=j < len(matrix) and matrix[i][j] == value:
matrix[i][j] = 0
return 1 + recursion(matrix, i + 1, j, value) + \
recursion(matrix, i - 1, j, value) + \
recursion(matrix, i, j + 1, value) + \
recursion(matrix, i, j - 1, value)
else:
return 0
def checkio(matrix):
count, values = [], []
for row, elem in enumerate(matrix):
for col, val in enumerate(elem):
if matrix[row][col]:
current_val = matrix[row][col]
values.append(current_val)
count.append(recursion(matrix, row, col, current_val))
index = count.index(max(count))
return [count[index], values[index]]
Dec. 9, 2015