Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Use of itertools.product solution in Creative category for Find Sequence by stqn
# migrated from python 2.7
from itertools import chain
from itertools import product as p
def checkio(matrix):
N = len(matrix)
u = [[i] * 4 for i in range(N)]
v = [list(range(i, i + 4)) for i in range(N - 3)]
w = list(map(list, list(map(reversed, v))))
for xs, ys in chain(p(u, v), p(v, u), p(v, v), p(v, w)):
if len(set([matrix[y][x] for x, y in zip(xs, ys)])) == 1:
return True
return False
March 22, 2014