You are viewing a single comment's thread. Return to all comments →
Here is my Python code utilizing list comprehensions! However, this does result in a line being incredibly long.
def cavityMap(grid): changes = [(i + 1, num + 1) for i in range(len(grid) - 2) for num in range(len(grid[i + 1]) - 2) if grid[i + 1][num] < grid[i + 1][num + 1] and grid[i + 1][num + 1] > grid[i + 1][num + 2] and grid[i][num + 1] < grid[i + 1][num + 1] and grid[i + 2][num + 1] < grid[i + 1][num + 1]] for change in changes: grid[change[0]] = grid[change[0]][:change[1]] + "X" + grid[change[0]][change[1] + 1:] return grid
Seems like cookies are disabled on this browser, please enable them to open this website
Cavity Map
You are viewing a single comment's thread. Return to all comments →
Here is my Python code utilizing list comprehensions! However, this does result in a line being incredibly long.