Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Radiation Search by TovarischZhukov
def find(matrix, complite, i, j, val, count=0):
if (i, j) not in complite and matrix[i][j] == val:
complite.append((i, j))
count += 1
count += find(matrix, complite, min(i + 1, len(matrix) - 1), j, val)
count += find(matrix, complite, max(i - 1, 0), j, val)
count += find(matrix, complite, i, min(j + 1, len(matrix[0]) - 1), val)
count += find(matrix, complite, i, max(j - 1, 0), val)
return count
def checkio (matrix, count=[0, 0]):
for i, elem in enumerate(matrix):
for j, val in enumerate(elem):
res = find(matrix, [], i, j, val)
if count[0] < res:
count = [res, val]
return count
Dec. 7, 2015