Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Not the longest but still the same solution in Clear category for Find Sequence by veky
def checkio(matrix):
indices = set(range(len(matrix)))
for i0 in indices:
for j0 in indices:
for di, dj in (1, 0), (0, 1), (1, 1), (1, -1):
i, j, initial, consecutive = i0, j0, matrix[i0][j0], 0
while {i, j} <= indices and matrix[i][j] == initial:
i += di
j += dj
consecutive += 1
if consecutive == 4:
return True
return False
March 13, 2017
Comments: