You are viewing a single comment's thread. Return to all comments →
Python3, not the most clever solution. I just check if there's a pattern in G starting at index (i,j).
def is_grid(G, P, g_i, g_j): p_m, p_n = len(P[0]), len(P) g_m, g_n = len(G[0]), len(G) if (g_i+p_n > g_n) or (g_j+p_m > g_m): return False for i in range(p_n): for j in range(p_m): if G[g_i+i][g_j+j] != P[i][j]: return False return True def gridSearch(G, P): g_m, g_n = len(G[0]), len(G) for i in range(g_n): for j in range(g_m): if is_grid(G, P, i, j): return 'YES' return 'NO'
Seems like cookies are disabled on this browser, please enable them to open this website
The Grid Search
You are viewing a single comment's thread. Return to all comments →
Python3, not the most clever solution. I just check if there's a pattern in G starting at index (i,j).