Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Find Sequence by Moff
def checkio(m):
n = len(m)
# columns
for row in range(n - 3):
for col in range(n):
x = m[row][col]
if all(m[row+i][col] == x for i in range(4)):
return True
# row
for col in range(n - 3):
for row in range(n):
x = m[row][col]
if all(m[row][col+i] == x for i in range(4)):
return True
# diagonal rigth-up
for row in range(3, n):
for col in range(n-3):
x = m[row][col]
if all([m[row-i][col+i] == x for i in range(4)]):
return True
# diagonal rigth-down
for row in range(n-3):
for col in range(n-3):
x = m[row][col]
if all([m[row+i][col+i] == x for i in range(4)]):
return True
return False
July 27, 2015