Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Short brute force solution in Clear category for Find Sequence by BertrandBordage
def checkio(M):
has_4 = lambda f: len({f(i) for i in range(4)}) == 1
D = len(M)
for y in range(D):
for x in range(D):
hori = has_4(lambda i: M[y][x+i]) if x < D-3 else False
vert = has_4(lambda i: M[y+i][x]) if y < D-3 else False
nwse = has_4(lambda i: M[y+i][x+i]) if y < D-3 and x < D-3 else False
nesw = has_4(lambda i: M[y+i][x-i]) if y < D-3 and x > 2 else False
if hori or vert or nwse or nesw:
return True
return False
Aug. 11, 2014