You are viewing a single comment's thread. Return to all comments →
Using some python built in functions would make you not have to write all those "and"s
def cavityMap(n,grid): modified=list(grid) for r in range(1,n-1): for c in range(1,n-1): if all([grid[r][c] > adj for adj in[grid[r+1][c],grid[r-1][c],grid[r][c+1],grid[r][c-1]]]): ss=list(modified[r]) ss[c]="X" modified[r]="".join(ss) return modified
Cavity Map
You are viewing a single comment's thread. Return to all comments →
Using some python built in functions would make you not have to write all those "and"s