You are viewing a single comment's thread. Return to all comments →
Same here, my script use indexOf too and fail several times, later I realized that the problem was in
input_stdin_array = input_stdin.split("\n");
adding this Regex in the split method /\r?\n/ will solve it.
My script with indexOf:
for(G_i = 0; G_i < R; G_i++){ max_index = G[0].length - P[0].length; for(k = 0; k <= max_index; k++){ match = 0; index = G[G_i].indexOf(P[0], k); if(index === -1 || G_i + r > R) continue ; match++; for(P_i=1; P_i index2 = G[G_i + P_i].indexOf(P[P_i], k); if(index2 !== index) break; match++; } if(match === r) break; } if(match === r) break; } if(match === r) console.log("YES"); else console.log("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 →
Same here, my script use indexOf too and fail several times, later I realized that the problem was in
adding this Regex in the split method /\r?\n/ will solve it.
My script with indexOf:
for(G_i = 0; G_i < R; G_i++){ max_index = G[0].length - P[0].length; for(k = 0; k <= max_index; k++){ match = 0; index = G[G_i].indexOf(P[0], k); if(index === -1 || G_i + r > R) continue ;
match++;
for(P_i=1; P_i index2 = G[G_i + P_i].indexOf(P[P_i], k); if(index2 !== index) break; match++;
} if(match === r) break; } if(match === r) break; } if(match === r) console.log("YES"); else console.log("NO");