You are viewing a single comment's thread. Return to all comments →
Python code
check if first line of pattern fits into grid.
if it does, check for every other line of the pattern.
for every other line of pattern that checks off, add 1 to lineChecks
once lineChecks == len(pattern) -1, return YES
once a line of pattern does not check off, lineChecks return to zero.
def gridSearch(G, P): lineChecks = 0 for i in range(len(G[0])-len(P[0])+1): for j in range(len(G)-len(P)+1): if G[j][i:i+len(P[0])] == P[0]: for x in range(1,len(P)): if G[j+x][i:i+len(P[0])] == P[x]: lineChecks +=1 if lineChecks == len(P) - 1: return "YES" else: lineChecks = 0 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 →
Python code
check if first line of pattern fits into grid.
if it does, check for every other line of the pattern.
for every other line of pattern that checks off, add 1 to lineChecks
once lineChecks == len(pattern) -1, return YES
once a line of pattern does not check off, lineChecks return to zero.