Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First - Find Sequence solution in Clear category for Find Sequence by AQiccl135
def checkio(matrix):
length = len(matrix)
# Checks horizontal
for x in range(length - 3):
for y in range(length):
if matrix[x][y] == matrix[x + 1][y] == matrix[x + 2][y] == matrix[x + 3][y]:
return True
# Check vertical
for x in range(length):
for y in range(length - 3):
if matrix[x][y] == matrix[x][y + 1] == matrix[x][y + 2] == matrix[x][y + 3]:
return True
# Check negative slope diagonal
for x in range(length - 3):
for y in range(length - 3):
if matrix[x][y] == matrix[x+1][y+1] == matrix[x+2][y+2] == matrix[x+3][y+3]:
return True
# Check posative slope diagonal
for x in range(3, length):
for y in range(length - 3):
if matrix[x][y] == matrix[x-1][y+1] == matrix[x-2][y+2] == matrix[x-3][y+3]:
return True
# If none are found ...
return False
Nov. 4, 2014
Comments: