Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
With chain rows/cols/diags generators solution in Clear category for Find Sequence by Phil15
from itertools import chain
def checkio(matrix):
"""Generate rows, columns, descending and ascending diagonals.
Then for each line, we look for 4 egals consecutives elements."""
check = lambda line: any(line[i]==line[i+1]==line[i+2]==line[i+3]
for i in range(len(line)-3))
N = len(matrix)
rows = (mat for mat in matrix)
cols = ([mat[j] for mat in matrix] for j in range(N))
d_diag = ([mat[i+k] for i,mat in enumerate(matrix) if 0<=i+k
July 24, 2018
Comments: