Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Straightforward solution in Clear category for Pattern Recognition by nickie
from itertools import product
def checkio(pattern, image):
N1, N2 = len(image), len(image[0])
M1, M2 = len(pattern), len(pattern[0])
for i, j in product(range(N1-M1+1), range(N2-M2+1)):
if all(image[i+k][j+l] == pattern[k][l]
for k, l in product(range(M1), range(M2))):
for k, l in product(range(M1), range(M2)):
image[i+k][j+l] = 2 + pattern[k][l]
return image
Feb. 20, 2014
Comments: