Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
10-liner: numpy slicing 2D-Arrays solution in 3rd party category for Pattern Recognition by Stensen
from ast import literal_eval as leval
import numpy as np
def checkio(pattern, image):
arr, r_len, c_len = np.array(image), len(pattern[0]), len(pattern)
for j in range(len(arr)):
for i in range(len(arr[0])):
stack = arr[j:j+c_len, i:i+r_len].tolist()
if stack == pattern:
arr[j:j+c_len, i:i+r_len] = leval(str(stack).replace('1','3').replace('0','2'))
return arr.tolist()
Oct. 26, 2020
Comments: