CarlosLabs
Hackerrank - Cavity map
{CM} I love mapping and topological problems. Visualization is a powerful thing.
#!/bin/python3 import math import os import random import re import sys # Complete the cavityMap function below. def cavityMap(grid): hW = wW = len(grid) - 1 ## make a true x/y grid tGrid = [] for ix, gRow in enumerate(grid): tGrid.append([]) for iy, gCol in enumerate(gRow): cell = gRow[iy:iy+1] tGrid[ix].append(cell) grid = [] row = '' ## scan and mark the deeper cells in 4 orthogonal cells for ix in range(0,hW+1): row='' for iy in range(0,wW+1): c = tGrid[ix][iy] if (ix > 0) and (ix < hW) and (iy > 0 and iy < wW): if (tGrid[ix-1][iy]