Ah okay, I didn't think of that. Thanks!
Read more… (8 words)
Could I have some help making my code faster? It's in python. It seems to implement the same method as shown in the hints except with this one it doesn't have a 2D array that stores info on whether or not a point is valid.
# Get inputsN, M = map(int,input().split())grid = [[int(i) for i in input().split()]for j in range(N)]charms = [[*map(int,input().split())] for i in range(M)]dp = [[None for n in range(N)] for m in range(N)]dp[0][0] = grid[0][0] # Base casedef valid_square(coord, charms):# Checks to see if a square is validfor charm in charms:if abs(coord[0]+1 - charm[0])+abs(coord[1]+1 - charm[1]) <= charm[2]:return Truereturn Falsefor y in range(N):for x in range(N):