Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Using set for sequence matching test. Set have to be equal to one. solution in Clear category for Find Sequence by von.Oak
def checkio(matrix):
len_mat = len(matrix)
for i_row, row in enumerate(matrix):
for i_item, item in enumerate(row):
if i_item + 3 < len_mat and len(set(matrix[i_row][i_item + i] for i in range(4))) == 1:
return True
if i_row + 3 < len_mat and len(set(matrix[i_row + i][i_item] for i in range(4))) == 1:
return True
if i_item + 3 < len_mat and i_row + 3 < len_mat and len(set(matrix[i_row + i][i_item + i] for i in range(4))) == 1:
return True
if i_item - 3 >= 0 and i_row + 3 < len_mat and len(set(matrix[i_row + i][i_item - i] for i in range(4))) == 1:
return True
return False
July 3, 2018
Comments: