You are viewing a single comment's thread. Return to all comments →
Can someone suggest me ways to optimise my code ?
r, c = map(int, input().split()) l, t, smallest_sum, point = [], [], None, None for i in range(r): l.append(list(map(int,input().split()))) h, w = map(int, input().split()) for i in range(h): t.append(list(map(int,input().split()))) for i in range(r-h+1): for j in range(c-w+1): temp_sum = 0 for m in range(h): for n in range(w): temp_sum += (l[i+m][j+n] - t[m][n])**2 if smallest_sum == None or smallest_sum > temp_sum: smallest_sum = temp_sum point = i,j, print("{}\n{} {}".format(smallest_sum, point[0]+1, point[1]+1))
Best spot
You are viewing a single comment's thread. Return to all comments →
Can someone suggest me ways to optimise my code ?